-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
53 lines (41 loc) · 1.28 KB
/
Copy pathserver.js
File metadata and controls
53 lines (41 loc) · 1.28 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
42
43
44
45
46
47
48
49
50
51
52
/**
* Created by monzys on 8/29/2016.
*/
//#!/usr/bin/env node
'use strict';
var express = require('express');
var bodyParser = require('body-parser');
var projects = require('./server/projects');
module.exports = (function() {
var port = 5000;
var init = function() {
var app = express();
app.use(express.static('.'));
app.use(bodyParser.json());
app.get('/api/projects', function (req, res) {
res.send(projects.getAll());
});
app.get('/api/projects/:id/vmrc', function (req, res) {
// call the method to gen the vmrc url
//console.log('calling genVmrc');
projects.genVmrc(req.params.id, function(url, err) {
// something happened getting the url
if (!url) {
//console.log('sending error: ' + err);
res.status(500).send(err);
}
// got it, so send it to the response
else {
//console.log('sending url: ' + url);
res.send({
url: url
});
}
});
});
app.listen(port, function () {
console.info('The server is listening at port ' + port);
});
}
init();
})();