-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (20 loc) · 722 Bytes
/
index.js
File metadata and controls
27 lines (20 loc) · 722 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
const express = require('express');
const http = require('http');
const bodyParser = require('body-parser'); // parse all requests as json
const morgan = require('morgan'); // middleware - logging
const cors = require('cors')
const mongoose = require('mongoose');
const app = express();
const router = require('./router');
// DB Setup
mongoose.connect('mongodb://localhost:auth/auth', { useUnifiedTopology: true, useNewUrlParser: true });
// App Setup
app.use(morgan('combined'));
app.use(cors());
app.use(bodyParser.json({ type: '*/*'}));
router(app);
// Server Setup
const port = process.env.PORT || 3090;
const server = http.createServer(app);
server.listen(port);
console.log("Server listening on port:", port);