-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (23 loc) · 1 KB
/
index.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 path = require('path');
// load up the express framework and body-parser helper
const express = require('./server/node_modules/express');
const bodyParser = require('./server/node_modules/body-parser');
// create an instance of express to serve our end points
const app = express();
app.use(express.static(__dirname + '/public'))
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
});
// we'll load up node's built in file system helper library here
// (we'll be using this later to serve our JSON files
const fs = require('fs');
// configure our express instance with some body-parser settings
// including handling JSON data
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// this is where we'll handle our various routes from
const routes = require('./server/routes/routes.js')(app, fs);
// finally, launch our server on port 3000.
const server = app.listen(3000, () => {
console.log('listening on port %s...', server.address().port);
});