-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
48 lines (35 loc) · 1.06 KB
/
index.js
File metadata and controls
48 lines (35 loc) · 1.06 KB
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
38
39
40
41
42
43
44
45
46
47
48
/* eslint no-console: ["error", { allow: ["info", "error"] }] */
// The main application script, ties everything together.
const bodyParser = require('body-parser');
const express = require('express');
const mongoose = require('mongoose');
const morgan = require('morgan');
const app = express();
const http = require('http').Server(app);
require('dotenv').config();
const config = require('./server/config/config');
// connect to Mongo when the app initializes
mongoose
.connect(config.database)
.then(() => console.info('Server connected to the database.'))
.catch((err) => console.error(err));
app.use(
bodyParser.urlencoded({
extended: true,
}),
);
app.use(bodyParser.json());
app.use(morgan('dev'));
app.use(express.static(`${__dirname}/public`));
const api = require('./server/routes/index')(app, express);
app.use('/api', api);
app.get('*', (req, res) => {
res.send('System Under Construction...');
});
http.listen(config.port, (err) => {
if (err) {
console.error(err);
} else {
console.info(`Listening on port: ${config.port}`);
}
});