milliparsec 2.2.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { ServerResponse as Response, IncomingMessage } from 'http';
3
4
  import { EventEmitter } from 'events';
4
- declare type NextFunction = (err?: any) => void;
5
- export declare type ReqWithBody<T = any> = IncomingMessage & {
5
+ type NextFunction = (err?: any) => void;
6
+ export type ReqWithBody<T = any> = IncomingMessage & {
6
7
  body?: T;
7
8
  } & EventEmitter;
8
9
  export declare const hasBody: (method: string) => boolean;
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ const custom = (fn) => async (req, _res, next) => {
18
18
  };
19
19
  const json = () => async (req, res, next) => {
20
20
  if (hasBody(req.method)) {
21
- req.body = await p((x) => JSON.parse(x.toString()))(req, res, next);
21
+ req.body = await p((x) => (x ? JSON.parse(x.toString()) : {}))(req, res, next);
22
22
  next();
23
23
  }
24
24
  else
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "milliparsec",
3
- "version": "2.2.2",
3
+ "version": "2.3.0",
4
4
  "description": "tiniest body parser in the universe",
5
5
  "repository": "https://github.com/talentlessguy/parsec.git",
6
6
  "author": "talentlessguy <pilll.PL22@gmail.com>",
@@ -18,22 +18,22 @@
18
18
  },
19
19
  "exports": "./dist/index.js",
20
20
  "devDependencies": {
21
- "@rollup/plugin-typescript": "6",
22
- "@tinyhttp/app": "^2.0.16",
23
- "@types/node": "^17.0.12",
24
- "c8": "7.11.0",
25
- "esbuild-node-loader": "^0.6.4",
26
- "rollup": "^2.66.1",
21
+ "@rollup/plugin-typescript": "^11.1.0",
22
+ "@tinyhttp/app": "^2.0.31",
23
+ "@types/node": "^18.16.3",
24
+ "c8": "7.13.0",
25
+ "rollup": "^3.21.4",
27
26
  "supertest-fetch": "^1.5.0",
28
- "tslib": "^2.3.1",
29
- "typescript": "^4.5.5",
30
- "uvu": "^0.5.3"
27
+ "tslib": "^2.5.0",
28
+ "tsm": "^2.3.0",
29
+ "typescript": "^5.0.4",
30
+ "uvu": "^0.5.6"
31
31
  },
32
32
  "files": [
33
33
  "dist"
34
34
  ],
35
35
  "scripts": {
36
- "test": "node --experimental-loader esbuild-node-loader test.ts",
36
+ "test": "uvu -r tsm",
37
37
  "test:coverage": "c8 --include=src pnpm test",
38
38
  "test:report": "c8 report --reporter=text-lcov > coverage.lcov",
39
39
  "build": "rollup -c"