-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
31 lines (25 loc) · 792 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
const express = require('express');
const bodyParser=require('body-parser');
const app = express();
const fs=require('fs');
const morgan=require('morgan');
const cors=require('cors');
const AppError=require('./utilities/appError');
const routes=require('./routes/analyticsRoute');
const globalErrorHandler=require('./controllers/errorController');
const schema=require('./utilities/Validation/schema');
const corsOptions={
"origin":"*",
optionsSuccessStatus:200
}
app.use(cors(corsOptions));
app.use(morgan('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:false}));
app.use('/',routes);
app.all('*',(req,res,next)=>
{
next(new AppError(`Cant find ${req.originalUrl} on this server`,404));
});
//app.use(globalErrorHandler);
module.exports = app;