-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
43 lines (34 loc) · 1.05 KB
/
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
40
41
42
43
#!/usr/bin/env node
// Guidelines
// aug2uag © 2015
var express = require('express')
, app = express()
, bParse = require('body-parser')
, Utils = require('./lib/utils');
app.use(bParse.json())
app.get('/', function(req, res) {
res.json({v: 'Guidelines v1.0.0'})
});
app.get('/disciplines', function(req, res) {
Utils.getDisciplines(function(err, result) {
if (err) throw err;
else res.json(result);
});
});
app.post('/get', function(req, res) {
Utils.getDiscipline(req.body.discipline, function(err, result) {
if (err) throw err;
else res.json(Object.keys(result));
});
});
app.post('/doc', function(req, res) {
Utils.getPDF(req.body.discipline, req.body.document, res);
});
app.post('/url', function(req, res) {
Utils.getPDF(req.body.discipline, req.body.document, res, true);
});
var _ipaddr = process.env.OPENSHIFT_NODEJS_IP || 'localhost';
var _port = process.env.OPENSHIFT_NODEJS_PORT || 9999;
app.listen(_port, _ipaddr, function() {
console.log('booted, all systems go || ' + new Date() + '\n' + Array(40).join('* '))
});