-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
50 lines (42 loc) · 2 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
require ('dotenv').config()
const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const indexRouter = require('./routes/index');
const usersRouter = require('./routes/users');
const ordersRouter = require ('./routes/orders');
const mediaRouter = require ('./routes/media');
const paymentsRouter = require ('./routes/payments');
const coursesRouter = require ('./routes/courses');
const lessonsRouter = require('./routes/lessons');
const imageCoursesRouter = require('./routes/imageCourses');
const chaptersRouter = require('./routes/chapters')
const refreshTokensRouter = require('./routes/refreshTokens');
const mentorsRouter = require('./routes/mentors')
const myCoursesRouter = require('./routes/myCourses')
const reviewsRouter = require('./routes/reviews')
const webhookRouter = require('./routes/webhook')
const verifyToken = require('./middlewares/verifyToken');
const can = require('./middlewares/permission');
const app = express();
app.use(logger('dev'));
app.use(express.json({limit:'50mb'}));
app.use(express.urlencoded({ extended: false, limit: '50mb' }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', indexRouter);
app.use('/users', usersRouter);
app.use('/courses',coursesRouter);
app.use('/chapters',verifyToken, can('admin'), chaptersRouter);
app.use('/lessons',verifyToken, can('admin'), lessonsRouter);
app.use('/image-courses', verifyToken,can('admin'),imageCoursesRouter);
app.use('/orders',verifyToken,can('admin', 'student'),ordersRouter);
app.use('/media', verifyToken, can('admin', 'student'), mediaRouter);
app.use('/payments', paymentsRouter);
app.use('/refresh-tokens', refreshTokensRouter);
app.use('/mentors', verifyToken,can('admin'), mentorsRouter);
app.use('/my-courses', verifyToken,can('admin', 'student'),myCoursesRouter)
app.use('/reviews', verifyToken, can('admin', 'student'), refreshTokensRouter);
app.use('/webhook', webhookRouter);
module.exports = app;