-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
42 lines (30 loc) · 990 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
32
33
34
35
36
37
38
39
40
41
42
const express = require('express');
const helmet = require('helmet');
require('dotenv').config();
const cors = require('cors');
const mongoose = require('mongoose');
const { errors } = require('celebrate');
const cookieParser = require('cookie-parser');
const { limiter } = require('./utils/rateLimitConfig');
const { requestLogger, errorLogger } = require('./middlewares/logger');
const { errorHandler } = require('./middlewares/error-handler');
const { PORT = 3000 } = process.env;
const app = express();
app.use(cookieParser());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors({
origin: ['https://movies--explorer.nomoredomainsicu.ru'],
credentials: true,
}));
mongoose.connect('mongodb://127.0.0.1:27017/bitfilmsdb', {
useNewUrlParser: true,
});
app.use(helmet());
app.use(requestLogger);
app.use(limiter);
app.use('', require('./routes/index'));
app.use(errorLogger);
app.use(errors());
app.use(errorHandler);
app.listen(PORT);