-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (30 loc) · 1.13 KB
/
index.js
File metadata and controls
41 lines (30 loc) · 1.13 KB
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
35
36
37
38
39
40
41
import express from 'express';
import bodyParser from 'body-parser';
import {myFund} from './my-fund';
import {deleteGlobal} from './delete-global';
import {saveGlobal} from './save-global';
var app = express()
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type');
next();
}
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(allowCrossDomain);
var port = process.env.PORT || 8000;
var router = express.Router();
router.get('/', function(req, res) {
res.json({ message: 'hooray! welcome to our api!' });
});
// REGISTER ROUTES -------------------------------
// all of our routes will be prefixed with /api
app.use('/api', router);
app.use('/api/my-fund', myFund());
app.use('/api/delete-global', deleteGlobal());
app.use('/api/save-global', saveGlobal());
// START THE SERVER
// =============================================================================
app.listen(port);
console.log('system run in ' + port);