-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
25 lines (22 loc) · 843 Bytes
/
index.js
File metadata and controls
25 lines (22 loc) · 843 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
// Main starting point for application
const express = require('express');
const http = require('http');
const bodyParser = require('body-parser');
const morgan = require('morgan');
const router = require('./router');
const mongoose = require('mongoose');
const cors = require('cors');
// Db setup
mongoose.connect('mongodb://localhost:auth/auth'); // creates an 'auth' database
// App setup
const app = express();
// load our middlewares
app.use(morgan('combined')); // logs http requests
app.use(cors()); // allows options to exclude specific domains if required for your project
app.use(bodyParser.json({ type: '*/*' })); // helps parse incoming http requests
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);