Skip to content

Commit

Permalink
modify docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lsongdev committed Nov 16, 2018
1 parent 8d78c00 commit e73997f
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 32 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,32 @@ http.createServer(app).listen(3000);
~$ npm run benchmark
```

> 2 GHz Intel Core i7 / 8 GB 1600 MHz DDR3 / v4.1.2
> MacBook Pro (Retina, 15-inch, Mid 2015) 2.2 GHz Intel Core i7 / 16 GB 1600 MHz DDR3 / 10.13.0
```bash
1 middleware
17710.10
22756.60

5 middleware
19057.27
21743.43

10 middleware
17320.05
21241.57

15 middleware
16792.36
19995.93

20 middleware
20580.80
19074.04

30 middleware
16053.46
18365.52

50 middleware
19124.45
16786.10

100 middleware
16800.39
12842.54
```

### Test
Expand Down
5 changes: 3 additions & 2 deletions benchmarks/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ while (n--) {
});
}

var body = new Buffer('Hello World');
var body = Buffer.from('Hello World');

app.use(function(req, res, next){
app.use(async (req, res, next) => {
res.statusCode = 200;
res.end(body);
next();
});

http.createServer(app).listen(3333);
19 changes: 14 additions & 5 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@
firstly, download [node.js][node.js] from [node.js official website ][node.js], and ...

```bash
mkdir myapp
git init
npm init
npm install kelp --save
~$ mkdir myapp
~$ git init
~$ npm init
~$ npm install kelp --save
```

```js
const app = require('kelp')();
const http = require('http');
const kelp = require('kelp');

const app = kelp();

app.use(async (req, res, next) => {
res.end('hello world');
});

http.createServer(app).listen(3000);
```

---
Expand Down
20 changes: 10 additions & 10 deletions docs/middlewares.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@

# Middleware

|name|description|
|-|
|kelp-body|parse request for kelp
| name | description |
|:-- | :-- |
|kelp-body |parse request for kelp
|kelp-logger|kelp logger
|kelp-send|ultimate library for send response
|kelp-gzip|gzip for kelp
|kelp-etag|etag for kelp
|kelp-auth|basic auth for kelp
|kelp-send |ultimate library for send response
|kelp-gzip |gzip for kelp
|kelp-etag |etag for kelp
|kelp-auth |basic auth for kelp
|kelp-static|serve static files for kelp
|kelp-cookie|cookie parser for kelp
|kelp-render|render template for kelp
|kelp-session|session manager for kelp
|kelp-co|wrap generator for kelp|
|kelp-error|kelp error handler
|kelp-proxy|proxy request to another backend
|kelp-co |wrap generator for kelp|
|kelp-error |kelp error handler
|kelp-proxy |proxy request to another backend
|kelp-config|Simple light-weight configuration for kelp :sparkles:
8 changes: 3 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ function Kelp() {
* @return {[type]} [undefined]
*/
function app(req, res) {
let self = this, i = -1;
var self = this, i = -1, mw;
(async function next(err) {
const middleware = app.stack[++i];
if (typeof middleware == 'function') {
return middleware.call(self, req, res, next, err);
}
mw = app.stack[++i];
return mw && mw.call(self, req, res, next, err);
})();
};
/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kelp",
"version": "2.0.1",
"version": "2.0.2",
"description": "dead simple nodejs http web framework",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit e73997f

Please sign in to comment.