-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (25 loc) · 801 Bytes
/
server.js
File metadata and controls
33 lines (25 loc) · 801 Bytes
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
// EXPRESS
const express = require('express')
const app = express()
const PORT = process.env.PORT || 3001
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
// MONGOOSE
const mongoose = require('mongoose')
mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost/Social-Network-Api', {
useNewUrlParser: true,
useUnifiedTopology: true
})
mongoose.connection.on('connected', () =>
console.log('Connected to MongoDB Endpoint')
);
mongoose.connection.on('error', (err) =>
console.log(`MONGOOSE DISCONNECTED ERROR: ${err}`)
);
mongoose.set('debug', true)
// FILES
app.use(require('./routes'));
// Server Listen
app.listen(PORT, () => {
console.log((`Connected on localhost:${PORT}`))
})