This repository has been archived on 2024-08-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
nubian/src/index.js

33 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-08-14 17:55:14 -06:00
// Imports
2021-07-24 15:42:36 -06:00
const express = require("express");
const bodyParser = require("body-parser");
const bearerToken = require("express-bearer-token");
2021-08-14 17:55:14 -06:00
// Local Imports
2021-07-24 15:42:36 -06:00
const { Web, StatusCode, Server } = require("./config.json");
2021-08-14 17:55:14 -06:00
// Import Routers
2021-07-24 15:42:36 -06:00
const stashRouter = require("./routes/stash");
2021-08-14 17:55:14 -06:00
// Define Constants & Setup Database
2021-07-24 15:42:36 -06:00
const app = express();
const port = Server.Port;
2021-08-14 17:55:14 -06:00
const timeout = 10 * 60 * 1000;
2021-07-24 15:42:36 -06:00
const debuggingMode = Server.Debug;
const viewOptions = { beautify: false };
2021-08-14 17:55:14 -06:00
// Set Up Express session and View engine
app.use(bearerToken());
2021-07-24 15:42:36 -06:00
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
2021-08-14 17:55:14 -06:00
app.use(["/nubian/api/stash", "/api/stash", "/stash"], stashRouter);
2021-07-24 15:42:36 -06:00
const startServer = () => {
2021-08-14 17:55:14 -06:00
var server = app.listen(port, () => {
2021-07-24 15:42:36 -06:00
console.log("Node version:" + process.versions.node);
console.log(`Duneserver listening on port ${port}!`);
});
2021-08-14 17:55:14 -06:00
server.timeout = timeout;
server.on("connection", (socket) => socket.setTimeout(timeout));
2021-07-24 15:42:36 -06:00
process.on("SIGINT", () => {
console.log("Recieved Shutdown Signal!");
process.exit();
});
};
startServer();