-
Notifications
You must be signed in to change notification settings - Fork 4
/
rest_api.js
34 lines (24 loc) · 1.03 KB
/
rest_api.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
// server.js
// BASE SETUP
// =============================================================================
// call the packages we need
var express = require('express'); // call express
var app = express(); // define our app using express
var bodyParser = require('body-parser');
var Engine = require('./engine');
var API = require('./api');
// configure app to use bodyParser()
// this will let us get the data from a POST
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
var port = process.env.PORT || 8080; // set our port
// Plumbing ====================================================================
var engine = new Engine();
engine.start();
var api = new API(engine);
// REST API ====================================================================
app.get('/transferPoints', api.transferPoints);
// START THE SERVER
// =============================================================================
app.listen(port);
console.log('Magic happens on port ' + port);