alp-body-parser 9.0.0 → 10.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,23 @@
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
+ ## [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
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * update dependencies and drop node 20
11
+ * update dev dependencies, replace parse-json-object-as-map with native JSON.parse, update koa
12
+ * update koa
13
+
14
+ ### Features
15
+
16
+ * update dependencies and drop node 20 ([fc5b322](https://github.com/christophehurpeau/alp/commit/fc5b322e076e9a3c7c4a235d16734b89fd85e211))
17
+ * update dev dependencies, replace parse-json-object-as-map with native JSON.parse, update koa ([5ae7723](https://github.com/christophehurpeau/alp/commit/5ae77238cafc573fe72c5eb63b103802b8b2e537))
18
+ * update koa ([e678114](https://github.com/christophehurpeau/alp/commit/e67811429d951287de715c3dffdbee7b798f3358))
19
+
20
+ Version bump for dependency: alp-node
21
+
22
+
6
23
  ## [9.0.0](https://github.com/christophehurpeau/alp/compare/alp-body-parser@8.1.1...alp-body-parser@9.0.0) (2024-01-06)
7
24
 
8
25
 
package/README.md CHANGED
@@ -1,16 +1,16 @@
1
- <h3 align="center">
1
+ <h1 align="center">
2
2
  alp-body-parser
3
- </h3>
3
+ </h1>
4
4
 
5
5
  <p align="center">
6
6
  body parser in alp framework
7
7
  </p>
8
8
 
9
9
  <p align="center">
10
- <a href="https://npmjs.org/package/alp-body-parser"><img src="https://img.shields.io/npm/v/alp-body-parser.svg?style=flat-square"></a>
11
- <a href="https://npmjs.org/package/alp-body-parser"><img src="https://img.shields.io/npm/dw/alp-body-parser.svg?style=flat-square"></a>
12
- <a href="https://npmjs.org/package/alp-body-parser"><img src="https://img.shields.io/node/v/alp-body-parser.svg?style=flat-square"></a>
13
- <a href="https://npmjs.org/package/alp-body-parser"><img src="https://img.shields.io/npm/types/alp-body-parser.svg?style=flat-square"></a>
10
+ <a href="https://npmjs.org/package/alp-body-parser"><img src="https://img.shields.io/npm/v/alp-body-parser.svg?style=flat-square" alt="npm version"></a>
11
+ <a href="https://npmjs.org/package/alp-body-parser"><img src="https://img.shields.io/npm/dw/alp-body-parser.svg?style=flat-square" alt="npm downloads"></a>
12
+ <a href="https://npmjs.org/package/alp-body-parser"><img src="https://img.shields.io/node/v/alp-body-parser.svg?style=flat-square" alt="node version"></a>
13
+ <a href="https://npmjs.org/package/alp-body-parser"><img src="https://img.shields.io/npm/types/alp-body-parser.svg?style=flat-square" alt="types"></a>
14
14
  </p>
15
15
 
16
16
  ## Install
@@ -22,9 +22,9 @@ npm install --save alp-body-parser
22
22
  ## Usage
23
23
 
24
24
  ```js
25
- import Koa from 'koa';
26
- import { config } from 'alp-node';
27
- import bodyParser from 'alp-body-parser';
25
+ import Koa from "koa";
26
+ import { config } from "alp-node";
27
+ import bodyParser from "alp-body-parser";
28
28
 
29
29
  const app = new Koa();
30
30
  config(`${__dirname}/config`, { packageConfig })(app);
@@ -1,5 +1,5 @@
1
- import Application from 'koa';
2
- declare module 'koa' {
1
+ import Application from "koa";
2
+ declare module "koa" {
3
3
  interface Request {
4
4
  body: any;
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,WAAwB,MAAM,KAAK,CAAC;AAE3C,OAAO,QAAQ,KAAK,CAAC;IACnB,UAAU,OAAO;QACf,IAAI,EAAE,GAAG,CAAC;KACX;IAED,UAAU,WAAW;QACnB,SAAS,EAAE,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;QAC/B,aAAa,EAAE,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;QACnC,aAAa,EAAE,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;KACpC;CACF;AAQD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAqB5D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,WAAwB,MAAM,KAAK,CAAC;AAE3C,OAAO,QAAQ,KAAK,CAAC;IACnB,UAAU,OAAO;QACf,IAAI,EAAE,GAAG,CAAC;KACX;IAED,UAAU,WAAW;QACnB,SAAS,EAAE,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;QAC/B,aAAa,EAAE,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;QACnC,aAAa,EAAE,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;KACpC;CACF;AAQD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CA2B5D"}
@@ -4,23 +4,23 @@ import parse from 'co-body';
4
4
 
5
5
  const assertBodyNotParsed = ctx => {
6
6
  if (ctx.request.body) {
7
- throw new Error('Request is already parsed');
7
+ throw new Error("Request is already parsed");
8
8
  }
9
9
  };
10
10
  function alpBodyParser(app) {
11
- app.context.parseBody = async function () {
11
+ app.context.parseBody = async function parseBody() {
12
12
  assertBodyNotParsed(this);
13
13
  const body = await parse.form(this);
14
14
  this.request.body = body;
15
15
  return body;
16
16
  };
17
- app.context.parseBodyJson = async function () {
17
+ app.context.parseBodyJson = async function parseBodyJson() {
18
18
  assertBodyNotParsed(this);
19
19
  const body = await parse.json(this);
20
20
  this.request.body = body;
21
21
  return body;
22
22
  };
23
- app.context.parseBodyText = async function () {
23
+ app.context.parseBodyText = async function parseBodyText() {
24
24
  assertBodyNotParsed(this);
25
25
  const body = await parse.text(this);
26
26
  this.request.body = body;
@@ -29,4 +29,4 @@ function alpBodyParser(app) {
29
29
  }
30
30
 
31
31
  export { alpBodyParser as default };
32
- //# sourceMappingURL=index-node18.mjs.map
32
+ //# sourceMappingURL=index-node20.mjs.map
@@ -0,0 +1 @@
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;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alp-body-parser",
3
- "version": "9.0.0",
3
+ "version": "10.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": ">=18.12.0"
22
+ "node": ">=20.11.0"
23
23
  },
24
24
  "sideEffects": false,
25
- "main": "./dist/index-node18.mjs",
25
+ "main": "./dist/index-node20.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-node18.mjs"
32
+ "import": "./dist/index-node20.mjs"
33
33
  }
34
34
  }
35
35
  },
@@ -43,33 +43,34 @@
43
43
  "clean": "yarn clean:build",
44
44
  "clean:build": "pob-babel-clean-out dist",
45
45
  "lint": "yarn run lint:eslint",
46
- "lint:eslint": "yarn ../.. run eslint --report-unused-disable-directives --resolve-plugins-relative-to . --quiet packages/alp-body-parser",
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
- "babelEnvs": [
50
+ "bundler": "rollup-babel",
51
+ "entries": [
52
+ "index"
53
+ ],
54
+ "envs": [
51
55
  {
52
56
  "target": "node",
53
- "version": "18"
57
+ "version": "20"
54
58
  }
55
- ],
56
- "entries": [
57
- "index"
58
59
  ]
59
60
  },
60
61
  "prettier": "@pob/root/prettier-config",
61
62
  "peerDependencies": {
62
- "alp-node": "^7.0.0"
63
+ "alp-node": "^8.0.0"
63
64
  },
64
65
  "dependencies": {
65
- "@types/co-body": "^6.0.0",
66
- "@types/koa": "^2.13.1",
67
- "co-body": "^6.0.0",
68
- "koa": "^2.13.1"
66
+ "@types/co-body": "^6.1.3",
67
+ "@types/koa": "^3.0.0",
68
+ "co-body": "^6.2.0",
69
+ "koa": "^3.0.1"
69
70
  },
70
71
  "devDependencies": {
71
- "@babel/core": "7.23.7",
72
- "pob-babel": "38.0.2",
73
- "typescript": "5.3.3"
72
+ "@babel/core": "7.28.0",
73
+ "pob-babel": "43.7.0",
74
+ "typescript": "5.8.3"
74
75
  }
75
76
  }
package/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
- import parse from 'co-body';
1
+ import parse from "co-body";
2
2
  // eslint-disable-next-line @typescript-eslint/consistent-type-imports
3
- import Application, { Context } from 'koa';
3
+ import Application, { Context } from "koa";
4
4
 
5
- declare module 'koa' {
5
+ declare module "koa" {
6
6
  interface Request {
7
7
  body: any;
8
8
  }
@@ -16,26 +16,32 @@ declare module 'koa' {
16
16
 
17
17
  const assertBodyNotParsed = (ctx: Context): void => {
18
18
  if (ctx.request.body) {
19
- throw new Error('Request is already parsed');
19
+ throw new Error("Request is already parsed");
20
20
  }
21
21
  };
22
22
 
23
23
  export default function alpBodyParser(app: Application): void {
24
- app.context.parseBody = async function <T>(this: Context): Promise<T> {
24
+ app.context.parseBody = async function parseBody<T>(
25
+ this: Context,
26
+ ): Promise<T> {
25
27
  assertBodyNotParsed(this);
26
28
  const body: T = (await parse.form(this)) as T;
27
29
  this.request.body = body;
28
30
  return body;
29
31
  };
30
32
 
31
- app.context.parseBodyJson = async function <T>(this: Context): Promise<T> {
33
+ app.context.parseBodyJson = async function parseBodyJson<T>(
34
+ this: Context,
35
+ ): Promise<T> {
32
36
  assertBodyNotParsed(this);
33
37
  const body: T = (await parse.json(this)) as T;
34
38
  this.request.body = body;
35
39
  return body;
36
40
  };
37
41
 
38
- app.context.parseBodyText = async function <T>(this: Context): Promise<T> {
42
+ app.context.parseBodyText = async function parseBodyText<T>(
43
+ this: Context,
44
+ ): Promise<T> {
39
45
  assertBodyNotParsed(this);
40
46
  const body: T = (await parse.text(this)) as T;
41
47
  this.request.body = body;
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-node18.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 <T>(this: Context): 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 <T>(this: Context): 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 <T>(this: Context): 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,CAAA;AAC9C,GAAA;AACF,CAAC,CAAA;AAEc,SAASC,aAAaA,CAACC,GAAgB,EAAQ;AAC5DA,EAAAA,GAAG,CAACC,OAAO,CAACC,SAAS,GAAG,kBAA8C;IACpER,mBAAmB,CAAC,IAAI,CAAC,CAAA;IACzB,MAAMG,IAAO,GAAI,MAAMM,KAAK,CAACC,IAAI,CAAC,IAAI,CAAO,CAAA;AAC7C,IAAA,IAAI,CAACR,OAAO,CAACC,IAAI,GAAGA,IAAI,CAAA;AACxB,IAAA,OAAOA,IAAI,CAAA;GACZ,CAAA;AAEDG,EAAAA,GAAG,CAACC,OAAO,CAACI,aAAa,GAAG,kBAA8C;IACxEX,mBAAmB,CAAC,IAAI,CAAC,CAAA;IACzB,MAAMG,IAAO,GAAI,MAAMM,KAAK,CAACG,IAAI,CAAC,IAAI,CAAO,CAAA;AAC7C,IAAA,IAAI,CAACV,OAAO,CAACC,IAAI,GAAGA,IAAI,CAAA;AACxB,IAAA,OAAOA,IAAI,CAAA;GACZ,CAAA;AAEDG,EAAAA,GAAG,CAACC,OAAO,CAACM,aAAa,GAAG,kBAA8C;IACxEb,mBAAmB,CAAC,IAAI,CAAC,CAAA;IACzB,MAAMG,IAAO,GAAI,MAAMM,KAAK,CAACK,IAAI,CAAC,IAAI,CAAO,CAAA;AAC7C,IAAA,IAAI,CAACZ,OAAO,CAACC,IAAI,GAAGA,IAAI,CAAA;AACxB,IAAA,OAAOA,IAAI,CAAA;GACZ,CAAA;AACH;;;;"}
@@ -1,31 +0,0 @@
1
- {
2
- "root": true,
3
- "parser": "@typescript-eslint/parser",
4
- "parserOptions": {
5
- "EXPERIMENTAL_useProjectService": true,
6
- "project": "packages/alp-body-parser/tsconfig.json"
7
- },
8
- "plugins": ["@typescript-eslint"],
9
- "extends": [
10
- "@pob/eslint-config-typescript",
11
- "@pob/eslint-config-typescript/node"
12
- ],
13
- "ignorePatterns": ["*.d.ts"],
14
- "overrides": [
15
- {
16
- "files": ["**/*.test.ts", "__tests__/**/*.ts"],
17
- "extends": ["@pob/eslint-config-typescript/test"],
18
- "env": {
19
- "jest": true
20
- },
21
- "rules": {
22
- "import/no-extraneous-dependencies": [
23
- "error",
24
- {
25
- "devDependencies": true
26
- }
27
- ]
28
- }
29
- }
30
- ]
31
- }