forked from oleg-codaio/HackMIT-2015
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
48 lines (38 loc) · 1.14 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
// Link Files
var db = require('./server/database');
var clarifai = require('./server/clarifai')
// Init Express
var express = require('express');
var app = express();
// Root route (ha).
app.get('/', function (req, res) {
res.send('Ooops! There\'s nothing here. We will win HackMIT(, though).');
});
app.get('/login/:username', function (req, res) {
//res.send({
// id: db.getIDForUsername(req.params.username)
//});
db.getIDForUsername(req.params, res);
});
// Post a single item.
// req header must include valid user ID.
app.post('/items', function (req, res) {
clarifai.handleImageUpload(req, res);
});
// Delete a single item.
// req header must include valid user ID.
app.delete('/items', function (req, res) {
db.deleteItem(req.params.id, req.params.itemid, res);
});
// Get all items.
// req header must include valid user ID.
app.get('/items', function (req, res) {
db.getItems(req.id, res);
});
// Mongo is running on: http://localhost:27017
// Init server.
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Listening at http://%s:%s', host, port);
});