This repository has been archived by the owner on May 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
router.js
55 lines (42 loc) · 1.73 KB
/
router.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
var site = require('./routes/site');
var api = require('./routes/api');
var FB = require('./helpers/fb');
module.exports = function(app){
/* ==== MAIN SITE ROUTES ==== */
app.get('/', site.home);
app.get('/browse', site.browse);
app.get('/browse/items/:itemID', site.browseItemDetail);
app.get('/browse/categories/:category', site.browseCategory);
app.get('/browse/users/:username', site.browseUser);
app.get('/checkout', site.checkout);
app.get('/manager', site.itemManager);
app.get('/manager/edit', site.itemManager);
app.get('/manager/create', site.itemManagerCreate);
// For Facebook integration
app.get('/login/callback', FB.loginCallback);
// Session logout
app.get('/logout', site.logout);
/* ======================================================== */
/* ==== API METHODS ==== */
// CRUD item
app.post('/api/all/items', api.createItem);
app.get('/api/all/items/:itemID', api.getItem);
app.delete('/api/me/items/:itemID', api.deleteItem);
app.delete('/api/cart/items/:itemID', api.deleteCartItem);
app.put('/api/me/items/:itemID', api.updateItem);
// R items
app.get('/api/all/items', api.getAllItems);
app.get('/api/users/:username/items', api.getUserItems);
app.get('/api/categories/:category/items', api.getCategoryItems);
app.get('/api/me/items', api.getMyItems);
app.get('/api/cart/items', api.getCartItems);
// Helper routes
app.get('/api/all/categories', api.getAllCategories);
// Iteraction with items
app.post('/api/all/items/:itemID/like', api.likeItem);
app.post('/api/all/items/:itemID/unlike', api.unlikeItem);
app.post('/api/all/items/:itemID/addToCart', api.addToCart);
// Uploads
app.post('/pictures/upload', api.uploadPic);
/* ========================================================= */
}