UNPKG

933 BJavaScriptView Raw
1var kick = require('../lib/kick')
2 // , profiler = require('v8-profiler')
3 , http = require('http');
4
5var redis = require('redis').createClient()
6
7var app = module.exports = kick();
8
9app.use(function(req, res, next) {
10 req.hello = 'hello world';
11 next();
12})
13
14app.get('/', function(req, res, next) {
15 res.end(req.hello);
16})
17
18app.get('/redis', function(req, res, next) {
19 redis.set('foo', 'bar', function(err, data) {
20 if(err) return next(err);
21 res.end(data)
22 })
23})
24
25function paramHandler(req, res, next) {
26 res.end(req.params.userid + req.hello);
27}
28
29// 30 handlers /user/1-30/:userid'
30for(var i = 1; i <= 30; i++)
31 app.get('/user/' + i + '/:userid/:itemid', paramHandler);
32
33// setInterval(function(){
34// profiler.startProfiling('flow');
35// setTimeout(function(){
36// profiler.stopProfiling('flow');
37// }, 100)
38// }, 1000)
39
40if(!module.parent) {
41 http.createServer(app).listen(3000);
42}
43