-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
50 lines (39 loc) · 1.35 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
44
45
46
47
48
49
50
var express = require('express'),
engines = require('consolidate'),
swig = require('swig'),
shelf = require('./server/modules/shelf.js');
var app = express();
app.set('title', 'Wgen Shelf');
app.engine('html', engines.swig);
// set .html as the default extension
app.set('view engine', 'html');
app.set('views', __dirname + '/client/tpl');
swig.init({ root: __dirname + '/client/tpl', allowErrors: true });
app.configure(function () {
app.use(express.logger('default')); /* 'default', 'short', 'tiny', 'dev' */
app.use(express.static(__dirname + '/client'));
app.use(express.bodyParser());
});
var port = process.env.PORT || 5002;
app.listen(port, function() {
console.log("Wgen Shelf Server Listening on " + port);
console.log(app.routes)
});
/******Routes*******/
app.get('/', function(req, res) {
res.render('index', {
app: 'Wgen Shelf'
});
});
app.get('/wgenshelf', function(req, res) {
res.render('index', {
app: 'Wgen Shelf'
});
});
app.get('/wgenshelf/component/:id', shelf.getComponent);
app.get('/wgenshelf/components', shelf.getComponents);
app.get('/wgenshelf/addcomponent', shelf.addComponent);
app.post('/wgenshelf/submitcomponent', shelf.submitComponent);
app.post('/wgenshelf/submitcomponent', shelf.submitComponent);
app.get('/wgenshelf/votecomponent/:id', shelf.voteComponent);
/******Routes*******/