-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
44 lines (36 loc) · 1.01 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
'use strict';
/**
* Module dependencies.
*/
(function() {
var express = require('express'),
json = require('express-json'),
basic = require('./routes/routes'),
item = require('./routes/item'),
passport = require('passport')
/*,
strategies = require('./passport')(passport)*/
;
//Connect to mongoDB
//mongoose = require('mongoose'),
//dbString = 'mongodb://localhost/philogi',
//mongoose.connect(dbString);
//var db = mongoose.connection;
var app = express();
app.use(json()); // to support JSON-encoded bodies
//use passport session
app.use(passport.initialize());
app.use(passport.session());
//routes should be at the last
//app.use(app.router);
//app.use('*', cors);
//Before all requests, call cors function.
app.all('*', basic.cors);
app.get('/get/items', item.getItems);
app.post('/update/item', item.updateItem);
app.post('/create/item', item.createItem);
app.get('/', basic.root);
app.listen(8000, function() {
console.log('server started, listening to port ' + 8000);
});
})();