-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
46 lines (35 loc) · 1.15 KB
/
Copy pathindex.js
File metadata and controls
46 lines (35 loc) · 1.15 KB
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
'use strict';
var restify = require('restify');
var vogels = require('vogels');
(function main() {
var server = restify.createServer({
name: 'user',
version: '0.0.1'
});
// Clean up sloppy paths like //todo//////1//
server.pre(restify.pre.sanitizePath());
// Handles annoying user agents (curl)
server.pre(restify.pre.userAgentConnection());
// use req.log
server.use(restify.requestLogger());
// Use the common stuff you probably want
server.use(restify.acceptParser(server.acceptable));
server.use(restify.dateParser());
server.use(restify.queryParser());//allows query string
server.use(restify.gzipResponse());
server.use(restify.jsonBodyParser( { mapParams: false })); //send in raw json, do not copy params from body
require('./lib/endpoint/user')(server);
require('./lib/endpoint/login')(server);
server.listen(8080, function onListening() {
console.log('listening on port 8080');
});
vogels.createTables({
'users': {readCapacity: 5, writeCapacity: 10},
}, function(err) {
if (err) {
console.log('Error creating tables: ', err);
} else {
console.log('Table created');
}
});
})();