forked from icyflame/yearbook-center-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
55 lines (44 loc) · 1.32 KB
/
index.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
var restify = require('restify');
var mongoose = require('mongoose');
// var util = require('util');
var server = restify.createServer();
server.use(restify.acceptParser(server.acceptable));
// server.use(restify.authorizationParser());
// server.use(restify.CORS());
server.use(restify.dateParser());
server.use(restify.queryParser());
server.use(restify.jsonp());
server.use(restify.gzipResponse());
server.use(restify.bodyParser());
// server.use(restify.requestExpiry());
// server.use(restify.throttle({
// burst: 100,
// rate: 50,
// ip: true,
// overrides: {
// '192.168.1.1': {
// rate: 0, // unlimited
// burst: 0
// }
// }
// }));
// server.use(restify.conditionalRequest());
mongoose.connect(process.env.MONGOLAB_DB_URL);
var userActions = require('./lib/userActions.js');
server.get('/users', userActions.getAllUsers);
server.post('/user', userActions.signUpUser);
server.post('/user/login', userActions.loginUser);
server.get('/user/logout', userActions.logoutUser);
server.get('/user/:id', userActions.getUserDetails);
server.get('/ping', function (req, res) {
res.json({
'message': 'Hello! The API is online!'
});
});
var port = process.env.PORT || 5000;
server.listen(port, function (err) {
if (err) {
throw err;
}
console.log('Started listeing on port ' + port);
});