-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
37 lines (31 loc) · 939 Bytes
/
server.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 mongoose = require('mongoose');
const http = require('http');
const cors = require('cors');
const express = require('express');
const morgan = require('morgan');
const profiles = require('./backendPart/routes/profiles');
const app = express();
app.use(
cors({
credentials: true,
origin: ['http://localhost:3000'],
optionsSuccessStatus: 200,
}),
);
app.use(morgan('dev'));
app.use(express.json({ limit: '50mb', extended: true }));
// app.use(express.urlencoded({ limit: '50mb', extended: true }));
app.use('/api/profiles', profiles);
const db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', () => {
console.log('connected to Atlas db');
});
mongoose.connect(
'mongodb+srv://developer:muvimo@v0.q0wxj.mongodb.net/V0?retryWrites=true&w=majority',
{
useNewUrlParser: true,
useUnifiedTopology: true,
},
);
http.createServer(app).listen(5000);