-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (28 loc) · 814 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
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const app = express();
const PORT = 3000;
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
mongoose.connect('mongodb://localhost:27017/mestodb', {
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
});
const cardsRouter = require('./routes/cards');
const usersRouter = require('./routes/users');
const errorRouter = require('./routes/errorUrl');
app.use((req, res, next) => {
req.user = {
_id: '6034ecd3c6e55d143c8dc6a7',
};
next();
});
app.use('/', cardsRouter);
app.use('/', usersRouter);
app.use('/', errorRouter);
app.listen(PORT, () => {
// eslint-disable-next-line no-console
console.log(`On port ${PORT}`);
});