Add session driver
This commit is contained in:
parent
057ee6e56d
commit
94c1dd5782
6 changed files with 135 additions and 1 deletions
|
@ -2,12 +2,20 @@ import * as config from "./config";
|
|||
import * as requests from "./requests";
|
||||
import { QueryResult } from "pg";
|
||||
import express from "express";
|
||||
import session from "express-session";
|
||||
import pgSessionStore from "connect-pg-simple";
|
||||
import db from "./db";
|
||||
import errorHandler from "./errors";
|
||||
|
||||
const app = express();
|
||||
app.use(express.static('public'));
|
||||
app.use(express.urlencoded({extended: false}));
|
||||
app.use(session({
|
||||
secret: config.sessionSecret,
|
||||
saveUninitialized: false,
|
||||
resave: false,
|
||||
store: new (pgSessionStore(session))()
|
||||
}));
|
||||
|
||||
app.get("/api/getRequests", async (request, response) => {
|
||||
var requestCount = ( request.query.count ? parseInt(request.query.count as string, 10) : 5 );
|
||||
|
|
|
@ -2,5 +2,10 @@ if (!process.env.PORT) {
|
|||
console.log("Missing environment variable PORT");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
export const port: number = parseInt(process.env.PORT as string, 10);
|
||||
|
||||
if (!process.env.SESSION_SECRET) {
|
||||
console.log("Missing environment variable SESSION_SECRET");
|
||||
process.exit(1);
|
||||
}
|
||||
export const sessionSecret: string = process.env.SESSION_SECRET;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue