achievements_project/frontend/static_server.js

26 lines
No EOL
546 B
JavaScript

const express = require('express' );
const morgan = require('morgan' );
const promptly = require('promptly');
const config = require('./config.js').load(process.argv[2]);
if (config.build === 'debug') {
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
}
const app = express();
app.use("/", morgan("dev"));
app.use("/", express.static("webpage"));
const server = app.listen(config.port);
const prompt = input => {
if (/q(?:uit)?|exit/i.test(input)) {
server.close();
} else {
promptly.prompt('')
.then(prompt);
}
};
prompt();