forked from DmitriyRud/career-coach-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
68 lines (57 loc) · 1.83 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const session = require('express-session');
const FileStore = require('session-file-store')(session);
const cors = require('cors');
require('dotenv').config();
const authRouter = require('./src/routes/auth.router');
const usersRouter = require('./src/routes/users.router');
const helperRouter = require('./src/routes/helper.router');
const userRouter = require('./src/routes/user.router');
const apiRouter = require('./src/routes/api.router');
const scrapRouter = require('./src/routes/scrap.router');
const recomRouter = require('./src/routes/recom.router');
const vacansiesRouter = require('./src/routes/vacansies.router');
const app = express();
const { COOKIE_SECRET, COOKIE_NAME } = process.env;
// SERVER'S SETTINGS
app.set('cookieName', COOKIE_NAME);
// APP'S MIDDLEWARES
app.use(
cors({
origin: true,
credentials: true,
}),
);
app.use(logger('dev'));
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.json());
app.use(
session({
name: app.get('cookieName'),
secret: COOKIE_SECRET,
resave: false,
saveUninitialized: false,
store: new FileStore(),
cookie: {
secure: false,
httpOnly: true,
maxAge: 1e3 * 86400, // COOKIE'S LIFETIME — 1 DAY
},
}),
);
// APP'S ROUTES
app.use('/auth', authRouter);
app.use('/helper', helperRouter);
app.use('/users/profile', userRouter)
app.use('/api', apiRouter);
app.use('/scrap', scrapRouter);
app.use('/users', usersRouter);
app.use('/recommend', recomRouter);
app.use('/bestvacansies', vacansiesRouter);
const PORT = process.env.PORT || 3001;
app.listen(PORT, () => console.log(`Start server to PORT = ${PORT}`))