-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
30 lines (23 loc) · 848 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
const bodyParser = require('body-parser');
const express = require('express');
const sets = require('./sets.js');
const setsRouter = sets.router;
const CreateErrorJson = sets.CreateErrorJson;
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(__dirname + "/site"));
app.get('/', function(req, res) {
res.sendFile(__dirname + '/site/index.html');
});
app.use(express.static(__dirname + "/client"));
app.get('/demo', function(req, res) {
res.sendFile(__dirname + '/client/index.html');
});
app.use('/', setsRouter);
app.all('/*', function(req, res) {
res.json(CreateErrorJson(404, "path", `${req.path} does not exist`));
});
console.log("Starting up API server!");
console.log(`Running on PORT: ${process.env.PORT || 3000}`);
app.listen(process.env.PORT || 3000);