-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.js
79 lines (64 loc) · 2.79 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
var express = require('express'),
bodyParser = require('body-parser'),
methodOverride = require('method-override'),
compression = require('compression'),
http = require('http'),
path = require('path'),
winston = require('winston'),
sqlinit = require('./server/sqlinit'),
// App modules
offers = require('./server/offers'),
products = require('./server/products'),
users = require('./server/users'),
//cases = require('./server/cases'),
wallet = require('./server/wallet'),
wishlist = require('./server/wishlist'),
stores = require('./server/stores'),
pictures = require('./server/pictures'),
auth = require('./server/auth'),
facebook = require('./server/facebook'),
s3signing = require('./server/s3signing'),
activities = require('./server/activities'),
app = express();
app.set('port', process.env.PORT || 5000);
app.use(compression());
// body-parser deprecated bodyParser() constructor: use individual json/urlencoded middleware
app.use(bodyParser.json({
uploadDir: __dirname + '/uploads',
keepExtensions: true
}));
app.use(methodOverride());
app.use(express.static(path.join(__dirname, './client')));
app.use(function(err, req, res, next) {
console.log(err.stack);
res.send(500, err.message);
});
app.post('/login', auth.login);
app.post('/logout', auth.validateToken, auth.logout);
app.post('/signup', auth.signup);
app.post('/fblogin', facebook.login);
app.get('/users/me', auth.validateToken, users.getProfile);
app.put('/users/me', auth.validateToken, users.updateProfile);
app.get('/offers', auth.validateToken, offers.getAll);
app.get('/offers/:id', offers.getById);
app.get('/products', products.getAll);
app.get('/products/:id', products.getById);
app.get('/stores', stores.findAll);
app.get('/wallet', auth.validateToken, wallet.getItems);
app.post('/wallet', auth.validateToken, wallet.addItem);
app.delete('/wallet/:id', auth.validateToken, wallet.deleteItem);
app.get('/wishlist', auth.validateToken, wishlist.getItems);
app.post('/wishlist', auth.validateToken, wishlist.addItem);
app.delete('/wishlist/:id', auth.validateToken, wishlist.deleteItem);
app.get('/pictures', auth.validateToken, pictures.getItems);
app.post('/pictures', auth.validateToken, pictures.addItem);
app.delete('/pictures', auth.validateToken, pictures.deleteItems);
app.get('/activities', auth.validateToken, activities.getItems);
app.post('/activities', auth.validateToken, activities.addItem);
app.delete('/activities', auth.validateToken, activities.deleteAll);
//app.post('/cases', auth.validateToken, cases.createCase);
//app.get('/nfrevoke', cases.revokeToken);
app.post('/s3signing', auth.validateToken, s3signing.sign);
app.listen(app.get('port'), function () {
console.log('Express server listening on port ' + app.get('port'));
});