-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
38 lines (29 loc) · 891 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 cors = require('cors');
const config = require('config');
const bodyParser = require('body-parser');
// список роутов для маршрута /api/auth + routes
const authRoutes = require('./routes/auth.routes');
const mongoose = require('mongoose');
const app = express();
app.use(cors());
app.use(bodyParser.json());
app.use('/api/auth', authRoutes);
const PORT = config.get('port') || 5000;
async function start() {
try {
await mongoose.connect(config.get('mongoUri'), {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
useCreateIndex: true
});
app.listen(PORT, () => {
console.log(`app has been started on port ${PORT}`);
});
} catch (e) {
console.log('Server error', e.message);
process.exit();
}
}
start();