-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.js
29 lines (23 loc) · 829 Bytes
/
app.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
/*globals cloudantService:true */
/*eslint-env node */
var express = require('express');
var bodyParser = require('body-parser');
var path = require('path');
var cors = require('cors');
console.log("PROCESS.ENV --------");
console.log(process.env);
//Retrieve Cloudant credentials from env variables
cloudantService = JSON.parse(process.env.CLOUDANT_SERVICE);
//Setup middleware.
var app = express();
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, 'www')));
//REST HTTP Methods
var orders = require('./routes/orders');
app.get('/rest/orders', orders.list);
app.get('/rest/orders/:id', orders.find);
app.post('/rest/orders', orders.create);
app.listen(process.env.WEB_PORT);
console.log('App started on ' + process.env.WEB_PORT);