-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
44 lines (32 loc) · 955 Bytes
/
app.js
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
import express from 'express';
import path from 'path';
import { fileURLToPath } from 'url';
import session from 'express-session';
import auth from './middleware/auth.js';
const app = express();
const PORT = process.env.PORT;
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Import routes
import publicRouter from './routes/public.js';
import userRouter from './routes/user.js';
import messageRouter from './routes/message.js';
import jobRouter from './routes/job.js';
//
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: true
}));
//
app.use(auth);
//
app.use(express.json());
// EJS
app.set('view engine', 'ejs');
app.set('views', 'views');
// Public folder
app.use(express.static(path.join(__dirname, 'public')));
// Routes
app.use('/', publicRouter, userRouter, messageRouter, jobRouter);
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));