forked from yannhodiesne/evo-scoreboard-api
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
31 lines (22 loc) · 753 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
const pkg = require("./package.json");
if (process.env.NODE_ENV !== "production") {
require("dotenv").config();
}
const express = require("express");
const bodyParser = require("body-parser");
const PORT = process.env.PORT || 80;
const app = express();
// Parse application/json requests
app.use(bodyParser.json());
app.get("/", (req, res) => {
res.send(`${pkg.name} version ${pkg.version} - ${pkg.description}`);
});
// Look for app/routes folder
const routesPath = require("path").join(__dirname, "app/routes");
// Register all routes in app/routes
require("fs").readdirSync(routesPath).forEach(file => {
require("./app/routes/" + file)(app);
});
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});