This repository was archived by the owner on Jul 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.ts
More file actions
56 lines (45 loc) · 1.28 KB
/
app.ts
File metadata and controls
56 lines (45 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import cors from "cors";
import cookieParser from "cookie-parser";
import createError from "http-errors";
import express, { Request, Response, NextFunction } from "express";
import { routes } from "./routes/routes";
import session from "express-session";
import { config } from "./config/config";
import { sessionStore } from "./auth/sess/sessionStore";
const PORT: number = parseInt(process.env.PORT as string) || 8864;
const HOST: string = process.env.HOST || "localhost";
const app = express();
app.disable("x-powered-by");
app.set("trust proxy", 1);
app.use(
session({
secret: config.session.secret,
store: sessionStore,
resave: false,
saveUninitialized: false,
proxy: true,
cookie: {
// domain: '.',
// path: '/',
signed: true,
maxAge: 60000,
secure: config.session.secure,
sameSite: "strict",
httpOnly: false,
},
})
);
// app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(routes);
app.use(function (err: Error, req: Request, res: Response, next: NextFunction) {
next(createError(404));
});
if (process.env.NODE_ENV !== "test") {
app.listen(PORT, HOST, () => {
console.log(`server start ${HOST}:${PORT}`);
});
}
export default app;