homepage.js/index.js

33 lines
872 B
JavaScript
Raw Normal View History

2023-02-13 02:16:46 +01:00
// do startup jobs
require('./startup');
const express = require('express');
const app = express();
2023-02-18 16:29:43 +01:00
const session = require('express-session');
const cookie_parse = require('cookie-parser');
const cookie_encrypt = require('cookie-encrypter');
2023-02-19 03:25:01 +01:00
const Redis = require("ioredis");
let redisClient = new Redis(process.env.REDIS_PORT, process.env.REDIS_HOST);
let RedisStore = require("connect-redis")(session)
2023-02-13 02:16:46 +01:00
2023-02-18 16:29:43 +01:00
const { APP_PORT, APP_KEY } = process.env;
2023-02-13 02:16:46 +01:00
app.use(require('./routes'));
2023-02-18 16:29:43 +01:00
app.use(express.static('public'));
app.use(cookie_parse(APP_KEY))
app.use(cookie_encrypt(APP_KEY));
app.use(session({
secret: APP_KEY,
2023-02-19 03:25:01 +01:00
resave: false,
saveUninitialized: true,
cookie: { secure: true },
store: new RedisStore({ client: redisClient })
2023-02-18 16:29:43 +01:00
}));
2023-02-19 03:25:01 +01:00
app.use(require('./middleware'));
2023-02-13 02:16:46 +01:00
const server = app.listen(APP_PORT, () => {
console.log("Listening on port " + APP_PORT);
});