3
3
<img src =" logo.png " width =" 400px " />
4
4
<br /><br />
5
5
6
- ![ Vulnerabilities] [ vulns-badge-url ]
7
6
[ ![ Version] [ v-badge-url ]] [ npm-url ] [ ![ Coverage] [ cov-img ]] [ cov-url ] [ ![ Github actions] [ gh-actions-img ]] [ github-actions ] [ ![ Downloads] [ dl-badge-url ]] [ npm-url ]
8
7
9
8
</div >
@@ -15,8 +14,7 @@ Check out [deno-libs/parsec](https://github.com/deno-libs/parsec) for Deno port.
15
14
16
15
## Features
17
16
18
- - ⏩ built with ` async ` / ` await `
19
- - 🛠 JSON / raw / urlencoded data support
17
+ - 🛠 JSON / raw / urlencoded / multipart support
20
18
- 📦 tiny package size (8KB dist size)
21
19
- 🔥 no dependencies
22
20
- ✨ [ tinyhttp] ( https://github.com/tinyhttp/tinyhttp ) and Express support
@@ -43,28 +41,14 @@ import { createServer } from 'node:http'
43
41
import { json } from ' milliparsec'
44
42
45
43
const server = createServer (async (req : ReqWithBody , res ) => {
46
- await json ()(req, res, (err ) => void err && console . log (err))
44
+ await json ()(req, res, (err ) => void err && res . end (err))
47
45
48
46
res .setHeader (' Content-Type' , ' application/json' )
49
47
50
48
res .end (JSON .stringify (req .body ))
51
49
})
52
50
```
53
51
54
- ### Web frameworks integration
55
-
56
- #### tinyhttp
57
-
58
- ``` ts
59
- import { App } from ' @tinyhttp/app'
60
- import { urlencoded } from ' milliparsec'
61
-
62
- new App ()
63
- .use (urlencoded ())
64
- .post (' /' , (req , res ) => void res .send (req .body ))
65
- .listen (3000 , () => console .log (` Started on http://localhost:3000 ` ))
66
- ```
67
-
68
52
## API
69
53
70
54
### ` raw(req, res, cb) `
@@ -111,7 +95,6 @@ res.end(req.body) // "THIS TEXT MUST BE UPPERCASED"
111
95
112
96
The parsec is a unit of length used to measure large distances to astronomical objects outside the Solar System.
113
97
114
- [ vulns-badge-url ] : https://img.shields.io/snyk/vulnerabilities/npm/milliparsec.svg?style=for-the-badge&color=25608B&label=vulns
115
98
[ v-badge-url ] : https://img.shields.io/npm/v/milliparsec.svg?style=for-the-badge&color=25608B&logo=npm&label=
116
99
[ npm-url ] : https://www.npmjs.com/package/milliparsec
117
100
[ dl-badge-url ] : https://img.shields.io/npm/dt/milliparsec?style=for-the-badge&color=25608B
0 commit comments