generated from webdevpt-0921/server-jwt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
26 lines (20 loc) · 793 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
require('dotenv/config');
require('./db');
const express = require('express');
const { isAuthenticated } = require('./middleware/jwt.middleware');
const allRoutes = require('./routes');
const authRouter = require('./routes/auth.routes');
const protectedRoute = require('./routes/protected.routes');
const diaryRouter = require('./routes/diary.routes');
const pageRouter = require('./routes/page.routes');
const userRouter = require('./routes/user.routes');
const app = express();
require('./config')(app);
app.use('/api', allRoutes);
app.use('/api/protected', isAuthenticated, protectedRoute);
app.use('/auth', authRouter);
app.use('/api/diaries', diaryRouter);
app.use('/api/pages', pageRouter);
app.use('/api/user', userRouter);
require('./error-handling')(app);
module.exports = app;