Refactored code
This commit is contained in:
parent
87952f467b
commit
e6009c5ac0
2 changed files with 4 additions and 10 deletions
14
src/index.js
14
src/index.js
|
@ -3,19 +3,17 @@ const express = require("express");
|
|||
const bodyParser = require("body-parser");
|
||||
const bearerToken = require("express-bearer-token");
|
||||
// Local Imports
|
||||
const { Web, StatusCode, Server } = require("./config.json");
|
||||
const { Server } = require("./config.json");
|
||||
// Import Routers
|
||||
const stashRouter = require("./routes/stash");
|
||||
const stashRouter = require("./routes/stash-route");
|
||||
// Define Constants & Setup Database
|
||||
const app = express();
|
||||
const port = Server.Port;
|
||||
const timeout = 10 * 60 * 1000;
|
||||
const debuggingMode = Server.Debug;
|
||||
const viewOptions = { beautify: false };
|
||||
// Set Up Express session and View engine
|
||||
app.use(bearerToken());
|
||||
app.use(bodyParser.json({ limit: Server.BodyLimit })); // parse application/json
|
||||
app.use(bodyParser.urlencoded({ limit: Server.BodyLimit, extended: false })); // parse application/x-www-form-urlencoded
|
||||
app.use(bodyParser.json({ limit: Server.BodyLimit }));
|
||||
app.use(bodyParser.urlencoded({ limit: Server.BodyLimit, extended: false }));
|
||||
app.use(["/nubian/api/stash", "/api/stash", "/stash"], stashRouter);
|
||||
const startServer = () => {
|
||||
var server = app.listen(port, () => {
|
||||
|
@ -24,9 +22,5 @@ const startServer = () => {
|
|||
});
|
||||
server.timeout = timeout;
|
||||
server.on("connection", (socket) => socket.setTimeout(timeout));
|
||||
process.on("SIGINT", () => {
|
||||
console.log("Recieved Shutdown Signal!");
|
||||
process.exit();
|
||||
});
|
||||
};
|
||||
startServer();
|
||||
|
|
Reference in a new issue