alp-body-parser 10.0.0 → 11.0.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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [11.0.0](https://github.com/christophehurpeau/alp/compare/alp-body-parser@10.0.0...alp-body-parser@11.0.0) (2025-10-27)
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
* drop node 20 and build using esbuild
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* drop node 20 and build using esbuild ([812c4c1](https://github.com/christophehurpeau/alp/commit/812c4c1b0ad19984e389af4382a8d1e60643e4f1))
|
|
15
|
+
|
|
16
|
+
Version bump for dependency: alp-node
|
|
17
|
+
|
|
18
|
+
|
|
6
19
|
## [10.0.0](https://github.com/christophehurpeau/alp/compare/alp-body-parser@9.0.0...alp-body-parser@10.0.0) (2025-08-02)
|
|
7
20
|
|
|
8
21
|
### ⚠ BREAKING CHANGES
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import parse from 'co-body';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const assertBodyNotParsed = ctx => {
|
|
3
|
+
const assertBodyNotParsed = (ctx) => {
|
|
6
4
|
if (ctx.request.body) {
|
|
7
5
|
throw new Error("Request is already parsed");
|
|
8
6
|
}
|
|
@@ -29,4 +27,4 @@ function alpBodyParser(app) {
|
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
export { alpBodyParser as default };
|
|
32
|
-
//# sourceMappingURL=index-
|
|
30
|
+
//# sourceMappingURL=index-node.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-node.mjs","sources":["../src/index.ts"],"sourcesContent":["import parse from \"co-body\";\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport Application, { Context } from \"koa\";\n\ndeclare module \"koa\" {\n interface Request {\n body: any;\n }\n\n interface BaseContext {\n parseBody: <T>() => Promise<T>;\n parseBodyJson: <T>() => Promise<T>;\n parseBodyText: <T>() => Promise<T>;\n }\n}\n\nconst assertBodyNotParsed = (ctx: Context): void => {\n if (ctx.request.body) {\n throw new Error(\"Request is already parsed\");\n }\n};\n\nexport default function alpBodyParser(app: Application): void {\n app.context.parseBody = async function parseBody<T>(\n this: Context,\n ): Promise<T> {\n assertBodyNotParsed(this);\n const body: T = (await parse.form(this)) as T;\n this.request.body = body;\n return body;\n };\n\n app.context.parseBodyJson = async function parseBodyJson<T>(\n this: Context,\n ): Promise<T> {\n assertBodyNotParsed(this);\n const body: T = (await parse.json(this)) as T;\n this.request.body = body;\n return body;\n };\n\n app.context.parseBodyText = async function parseBodyText<T>(\n this: Context,\n ): Promise<T> {\n assertBodyNotParsed(this);\n const body: T = (await parse.text(this)) as T;\n this.request.body = body;\n return body;\n };\n}\n"],"names":[],"mappings":";;AAgBA,MAAM,mBAAA,GAAsB,CAAC,GAAA,KAAuB;AAClD,EAAA,IAAI,GAAA,CAAI,QAAQ,IAAA,EAAM;AACpB,IAAA,MAAM,IAAI,MAAM,2BAA2B,CAAA;AAAA;AAE/C,CAAA;AAEA,SAAwB,cAAc,GAAA,EAAwB;AAC5D,EAAA,GAAA,CAAI,OAAA,CAAQ,SAAA,GAAY,eAAe,SAAA,GAEzB;AACZ,IAAA,mBAAA,CAAoB,IAAI,CAAA;AACxB,IAAA,MAAM,IAAA,GAAW,MAAM,KAAA,CAAM,IAAA,CAAK,IAAI,CAAA;AACtC,IAAA,IAAA,CAAK,QAAQ,IAAA,GAAO,IAAA;AACpB,IAAA,OAAO,IAAA;AAAA,GACT;AAEA,EAAA,GAAA,CAAI,OAAA,CAAQ,aAAA,GAAgB,eAAe,aAAA,GAE7B;AACZ,IAAA,mBAAA,CAAoB,IAAI,CAAA;AACxB,IAAA,MAAM,IAAA,GAAW,MAAM,KAAA,CAAM,IAAA,CAAK,IAAI,CAAA;AACtC,IAAA,IAAA,CAAK,QAAQ,IAAA,GAAO,IAAA;AACpB,IAAA,OAAO,IAAA;AAAA,GACT;AAEA,EAAA,GAAA,CAAI,OAAA,CAAQ,aAAA,GAAgB,eAAe,aAAA,GAE7B;AACZ,IAAA,mBAAA,CAAoB,IAAI,CAAA;AACxB,IAAA,MAAM,IAAA,GAAW,MAAM,KAAA,CAAM,IAAA,CAAK,IAAI,CAAA;AACtC,IAAA,IAAA,CAAK,QAAQ,IAAA,GAAO,IAAA;AACpB,IAAA,OAAO,IAAA;AAAA,GACT;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alp-body-parser",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "body parser in alp framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"alp",
|
|
@@ -19,17 +19,17 @@
|
|
|
19
19
|
},
|
|
20
20
|
"type": "module",
|
|
21
21
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
22
|
+
"node": ">=22.18.0"
|
|
23
23
|
},
|
|
24
24
|
"sideEffects": false,
|
|
25
|
-
"main": "./dist/index-
|
|
25
|
+
"main": "./dist/index-node.mjs",
|
|
26
26
|
"types": "./dist/definitions/index.d.ts",
|
|
27
27
|
"exports": {
|
|
28
28
|
"./package.json": "./package.json",
|
|
29
29
|
".": {
|
|
30
30
|
"types": "./dist/definitions/index.d.ts",
|
|
31
31
|
"node": {
|
|
32
|
-
"import": "./dist/index-
|
|
32
|
+
"import": "./dist/index-node.mjs"
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
},
|
|
@@ -41,26 +41,28 @@
|
|
|
41
41
|
"build": "yarn clean:build && rollup --config rollup.config.mjs && yarn run build:definitions",
|
|
42
42
|
"build:definitions": "tsc -p tsconfig.json",
|
|
43
43
|
"clean": "yarn clean:build",
|
|
44
|
-
"clean:build": "pob-
|
|
44
|
+
"clean:build": "pob-esbuild-clean-out dist",
|
|
45
45
|
"lint": "yarn run lint:eslint",
|
|
46
46
|
"lint:eslint": "yarn ../.. run eslint --quiet packages/alp-body-parser",
|
|
47
47
|
"watch": "yarn clean:build && rollup --config rollup.config.mjs --watch"
|
|
48
48
|
},
|
|
49
49
|
"pob": {
|
|
50
|
-
"bundler": "rollup-
|
|
50
|
+
"bundler": "rollup-esbuild",
|
|
51
51
|
"entries": [
|
|
52
52
|
"index"
|
|
53
53
|
],
|
|
54
54
|
"envs": [
|
|
55
55
|
{
|
|
56
56
|
"target": "node",
|
|
57
|
-
"version": "
|
|
57
|
+
"version": "22",
|
|
58
|
+
"omitVersionInFileName": true
|
|
58
59
|
}
|
|
59
|
-
]
|
|
60
|
+
],
|
|
61
|
+
"typescript": true
|
|
60
62
|
},
|
|
61
63
|
"prettier": "@pob/root/prettier-config",
|
|
62
64
|
"peerDependencies": {
|
|
63
|
-
"alp-node": "^
|
|
65
|
+
"alp-node": "^9.0.0"
|
|
64
66
|
},
|
|
65
67
|
"dependencies": {
|
|
66
68
|
"@types/co-body": "^6.1.3",
|
|
@@ -69,8 +71,7 @@
|
|
|
69
71
|
"koa": "^3.0.1"
|
|
70
72
|
},
|
|
71
73
|
"devDependencies": {
|
|
72
|
-
"@
|
|
73
|
-
"
|
|
74
|
-
"typescript": "5.8.3"
|
|
74
|
+
"@pob/rollup-esbuild": "6.7.0",
|
|
75
|
+
"typescript": "5.9.2"
|
|
75
76
|
}
|
|
76
77
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-node20.mjs","sources":["../src/index.ts"],"sourcesContent":["import parse from \"co-body\";\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport Application, { Context } from \"koa\";\n\ndeclare module \"koa\" {\n interface Request {\n body: any;\n }\n\n interface BaseContext {\n parseBody: <T>() => Promise<T>;\n parseBodyJson: <T>() => Promise<T>;\n parseBodyText: <T>() => Promise<T>;\n }\n}\n\nconst assertBodyNotParsed = (ctx: Context): void => {\n if (ctx.request.body) {\n throw new Error(\"Request is already parsed\");\n }\n};\n\nexport default function alpBodyParser(app: Application): void {\n app.context.parseBody = async function parseBody<T>(\n this: Context,\n ): Promise<T> {\n assertBodyNotParsed(this);\n const body: T = (await parse.form(this)) as T;\n this.request.body = body;\n return body;\n };\n\n app.context.parseBodyJson = async function parseBodyJson<T>(\n this: Context,\n ): Promise<T> {\n assertBodyNotParsed(this);\n const body: T = (await parse.json(this)) as T;\n this.request.body = body;\n return body;\n };\n\n app.context.parseBodyText = async function parseBodyText<T>(\n this: Context,\n ): Promise<T> {\n assertBodyNotParsed(this);\n const body: T = (await parse.text(this)) as T;\n this.request.body = body;\n return body;\n };\n}\n"],"names":["assertBodyNotParsed","ctx","request","body","Error","alpBodyParser","app","context","parseBody","parse","form","parseBodyJson","json","parseBodyText","text"],"mappings":";;AACA;;AAeA,MAAMA,mBAAmB,GAAIC,GAAY,IAAW;AAClD,EAAA,IAAIA,GAAG,CAACC,OAAO,CAACC,IAAI,EAAE;AACpB,IAAA,MAAM,IAAIC,KAAK,CAAC,2BAA2B,CAAC;AAC9C;AACF,CAAC;AAEc,SAASC,aAAaA,CAACC,GAAgB,EAAQ;EAC5DA,GAAG,CAACC,OAAO,CAACC,SAAS,GAAG,eAAeA,SAASA,GAElC;IACZR,mBAAmB,CAAC,IAAI,CAAC;IACzB,MAAMG,IAAO,GAAI,MAAMM,KAAK,CAACC,IAAI,CAAC,IAAI,CAAO;AAC7C,IAAA,IAAI,CAACR,OAAO,CAACC,IAAI,GAAGA,IAAI;AACxB,IAAA,OAAOA,IAAI;GACZ;EAEDG,GAAG,CAACC,OAAO,CAACI,aAAa,GAAG,eAAeA,aAAaA,GAE1C;IACZX,mBAAmB,CAAC,IAAI,CAAC;IACzB,MAAMG,IAAO,GAAI,MAAMM,KAAK,CAACG,IAAI,CAAC,IAAI,CAAO;AAC7C,IAAA,IAAI,CAACV,OAAO,CAACC,IAAI,GAAGA,IAAI;AACxB,IAAA,OAAOA,IAAI;GACZ;EAEDG,GAAG,CAACC,OAAO,CAACM,aAAa,GAAG,eAAeA,aAAaA,GAE1C;IACZb,mBAAmB,CAAC,IAAI,CAAC;IACzB,MAAMG,IAAO,GAAI,MAAMM,KAAK,CAACK,IAAI,CAAC,IAAI,CAAO;AAC7C,IAAA,IAAI,CAACZ,OAAO,CAACC,IAAI,GAAGA,IAAI;AACxB,IAAA,OAAOA,IAAI;GACZ;AACH;;;;"}
|