Implement checkVersion middleware
Checks version on each request, terminating the application if version mdoes not match
This commit is contained in:
parent
35aa0914a2
commit
21650994d2
2 changed files with 22 additions and 1 deletions
|
@ -8,6 +8,7 @@ import session from "express-session";
|
|||
import pg from "pg";
|
||||
import pgSessionStore from "connect-pg-simple";
|
||||
import fetch, { Response as FetchResponse } from "node-fetch";
|
||||
import { log, LogLevel } from "./logging"
|
||||
import cron from "./cron";
|
||||
import db from "./db";
|
||||
import errorHandler from "./errors";
|
||||
|
@ -26,6 +27,7 @@ async function validateApiToken(session: Express.Session) {
|
|||
}
|
||||
|
||||
const app = express();
|
||||
app.use(version.checkVersionMiddleware);
|
||||
app.use(express.static('public'));
|
||||
app.use(express.urlencoded({extended: false}));
|
||||
app.use(session({
|
||||
|
@ -340,4 +342,8 @@ version.checkVersion().then(_ => app.listen(config.port, () => {
|
|||
cron.run();
|
||||
setInterval(cron.run,config.cronInterval);
|
||||
console.log(`Listening on port ${config.port}`);
|
||||
}));
|
||||
}))
|
||||
.catch((e) => {
|
||||
log(LogLevel.ERROR,e)
|
||||
process.exit(1);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue