-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
28 lines (22 loc) · 901 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
const express = require('express');
const bodyparser = require('body-parser');
const APPError = require('./utils/appError');
const globalErrorHandler = require('./controllers/errorContoller');
const categoryRouter = require('./routers/categoryRoutes');
const subjectRouter = require('./routers/subjectRoutes');
const userRouter = require('./routers/userRoutes');
const lessonRouter = require('./routers/lessonRoutes');
const app = express();
app.use(express.json({ limit: '10kb' }));
app.use(bodyparser.urlencoded({ limit: '10mb', extended: false }));
//routes
app.use('/api/v1/category', categoryRouter);
app.use('/api/v1/subject', subjectRouter);
app.use('/api/v1/user', userRouter);
app.use('/api/v1/lesson', lessonRouter);
app.all('*', (req, res, next) => {
next(new AppError(`Cant find ${req.originalUrl} on this server`));
});
//errors
app.use(globalErrorHandler);
module.exports = app;