forked from ideal-postcodes/postcodes.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
34 lines (25 loc) · 885 Bytes
/
server.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
34
"use strict";
const path = require("path");
const env = process.env.NODE_ENV || "development";
const config = require(path.join(__dirname, "config/config"))(env);
if (env === "test" || process.env.PMX) {
require('pmx').init({
http : true
});
}
const express = require("express");
const app = express();
require(path.join(__dirname, "/config/logger"))(app, config);
require(path.join(__dirname, "/config/db"))(config);
require(path.join(__dirname, "/config/express"))(app, config);
require(path.join(__dirname, "/config/routes"))(app);
require(path.join(__dirname, "/config/renderer"))(app);
const port = config.port || 8000;
const server = app.listen(port);
server.on("clientError", (error, socket) => {
if (!socket.destroyed) {
socket.end('HTTP/1.1 400 Bad Request\r\n\r\n');
}
});
console.log("Postcode API listening on port", port);
exports = module.exports = app;