Skip to content

Commit afecb1a

Browse files
authored
Update Repo + Add Html Parser (#134)
* use const/let over var --ES+ features πŸ™ŒπŸ» .. * update example.js --better ✨ .. * update test file by add --spec πŸ§ͺ.. * avoid generating package-lock.json β˜”οΈ .. * update .gitignore file 🐞 .. * lint files πŸ’…πŸ» .. * update README.md πŸ“‹ .. * update README.md πŸ“‹ .. * add huskyrc --git --hooks 🐺 .. * update travis ci pipeline πŸ‘¨πŸΌβ€πŸ”§ .. * add code for parse html πŸ“Œ .. * add test for parse html πŸ§ͺ.. * better pkg.json πŸŽ— ..
1 parent ecc6ebf commit afecb1a

13 files changed

+566
-623
lines changed

β€Ž.gitignore

+20-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
lib-cov
2-
*.seed
3-
*.log
4-
*.csv
5-
*.dat
6-
*.out
7-
*.pid
8-
*.gz
1+
# OS #
2+
###################
3+
.DS_Store
4+
.idea
5+
Thumbs.db
6+
tmp/
7+
temp/
98

10-
pids
11-
logs
12-
results
139

14-
npm-debug.log
10+
# Node.js #
11+
###################
1512
node_modules
16-
coverage/
13+
package-lock.json
14+
yarn.lock
15+
npm-debug.log
16+
yarn-debug.log
17+
yarn-error.log
18+
1719

18-
.idea/
20+
# NYC #
21+
###################
22+
coverage
23+
*.lcov
24+
.nyc_output

β€Ž.huskyrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"hooks": {
3+
"pre-commit": "npm run lint"
4+
}
5+
}

β€Ž.jshintignore

-4
This file was deleted.

β€Ž.jshintrc

-95
This file was deleted.

β€Ž.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

β€Ž.travis.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
language: node_js
22
node_js:
3-
- "8"
4-
- "10"
5-
script: "make test-travis"
6-
after_script: "npm install [email protected] && cat ./coverage/lcov.info | coveralls"
3+
- 8
4+
- 10
5+
- 12
6+
- stable
7+
script:
8+
- npm run test-ci
9+
after_script:
10+
- npm install coveralls
11+
- cat ./coverage/lcov.info | coveralls

β€ŽMakefile

-45
This file was deleted.

β€ŽREADME.md

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
koa-bodyparser
2-
===============
1+
# [**koa-bodyparser**](https://github.com/koajs/bodyparser)
2+
33

44
[![NPM version][npm-image]][npm-url]
55
[![build status][travis-image]][travis-url]
66
[![Coveralls][coveralls-image]][coveralls-url]
77
[![David deps][david-image]][david-url]
88
[![node version][node-image]][node-url]
9-
[![Gittip][gittip-image]][gittip-url]
109

1110
[npm-image]: https://img.shields.io/npm/v/koa-bodyparser.svg?style=flat-square
1211
[npm-url]: https://npmjs.com/package/koa-bodyparser
@@ -16,11 +15,8 @@ koa-bodyparser
1615
[coveralls-url]: https://coveralls.io/r/koajs/bodyparser?branch=master
1716
[david-image]: https://img.shields.io/david/koajs/bodyparser.svg?style=flat-square
1817
[david-url]: https://david-dm.org/koajs/bodyparser
19-
[node-image]: https://img.shields.io/badge/node.js-%3E=_7.6-green.svg?style=flat-square
18+
[node-image]: https://img.shields.io/badge/node.js-%3E=_8-green.svg?style=flat-square
2019
[node-url]: http://nodejs.org/download/
21-
[gittip-image]: https://img.shields.io/gittip/dead-horse.svg?style=flat-square
22-
[gittip-url]: https://www.gittip.com/dead-horse/
23-
2420

2521
A body parser for koa, based on [co-body](https://github.com/tj/co-body). support `json`, `form` and `text` type body.
2622

@@ -33,10 +29,10 @@ A body parser for koa, based on [co-body](https://github.com/tj/co-body). suppor
3329
## Usage
3430

3531
```js
36-
var Koa = require('koa');
37-
var bodyParser = require('koa-bodyparser');
32+
const Koa = require('koa');
33+
const bodyParser = require('koa-bodyparser');
3834

39-
var app = new Koa();
35+
const app = new Koa();
4036
app.use(bodyParser());
4137

4238
app.use(async ctx => {
@@ -110,6 +106,6 @@ To use `koa-bodyparser` with koa@1, please use [bodyparser 2.x](https://github.c
110106
npm install koa-bodyparser@2 --save
111107
```
112108

113-
## Licences
114-
109+
#### Licences
110+
---
115111
[MIT](LICENSE)

β€Žexample.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
var koa = require('koa');
2-
var bodyParser = require('./');
1+
const Koa = require('koa');
2+
const bodyParser = require('.');
33

4-
var app = koa();
4+
const app = new Koa();
55
app.use(bodyParser());
66

7-
app.use(function *() {
7+
app.use(async function() {
88
// the parsed body will store in this.request.body
99
this.body = this.request.body;
1010
});
1111

12-
app.listen(3000);
12+
const PORT = process.env.PORT || 3000;
13+
14+
app.listen(PORT, () =>
15+
console.log(`Server ready at http://localhost:${PORT} πŸš€ ..`)
16+
);

0 commit comments

Comments
Β (0)