-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
42 lines (33 loc) · 932 Bytes
/
app.ts
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
import express, { Express } from "express";
import session from "express-session";
import dotenv from "dotenv";
// Import routes
import userRouter from "./routes/users";
import logsRouter from "./routes/logs";
import todoRouter from "./routes/todos";
import eventRouter from "./routes/events";
declare module 'express-session' {
interface SessionData {
user_id: number;
}
}
// Load environment variables
dotenv.config();
const app: Express = express();
// Middleware for parsing JSON
app.use(express.json());
// Middleware for session
app.use(session({
secret: process.env.SESSION_SECRET as string,
resave: false,
saveUninitialized: true,
cookie: {
secure: false // cookie is only accessible over HTTP, requires HTTPS
}
}));
// Routes
app.use("/users", userRouter);
app.use("/logs", logsRouter);
app.use("/todos", todoRouter);
app.use("/events", eventRouter);
export default app;