forked from OriginProtocol/civic-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
39 lines (27 loc) · 818 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
32
33
34
35
36
37
38
39
'use strict';
const express = require('express');
const bodyParser = require('body-parser');
require('dotenv').config();
console.log(process.env);
// Constants
const PORT = process.env.SERVER_PORT || 8080;
const HOST = process.env.SERVER_HOST|| '0.0.0.0';
// App
const app = express();
// for parsing application/json
app.use(bodyParser.json());
//CORS
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
var routes = {
civic: require( './lib/routes/civic' ),
test: require( './lib/routes/test' )
};
// Routes
app.use( '/civic', routes.civic );
app.use( '/', routes.test );
app.listen(PORT, HOST);
console.log(`Running on http://${HOST}:${PORT}`);