-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
24 lines (21 loc) · 780 Bytes
/
Copy pathindex.js
File metadata and controls
24 lines (21 loc) · 780 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
// Main starting point of application
const express = require('express');
const http = require('http'); // native node library for working with http requests
const bodyParser = require('body-parser');
const morgan = require('morgan');
const app = express();
const router = require('./router');
const mongoose = require('mongoose');
const cors = require('cors');
// DB Setup
mongoose.connect('mongodb://localhost:auth/auth');
// 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); // create an HTTP server that receives requests and forwards them to app
server.listen(port);
console.log("Server listening on port " + port);