-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
33 lines (27 loc) · 871 Bytes
/
app.js
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
/**
* Created by Joshua.Austill on 3/2/2017.
*/
const express = require("express");
const app = express();
const compression = require('compression');
app.use(compression());
const bodyParser = require("body-parser"),
environment = require("./environment"),
mongoose = require("mongoose"),
path = require("path");
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
// global variable for the running directory, why isn't this a thing??
global.__appRoot = path.normalize(__dirname);
mongoose.Promise = global.Promise;
mongoose.connect(environment.connectionString, {
useMongoClient: true,
});
app.use(require('./routers'));
app.use((req, res) => {
res.sendStatus(404);
});
const server = app.listen(3000, () => {
const port = server.address().port;
console.log("rmcapi server listening on port %s.", port);
});