Skip to content

Commit bc7318a

Browse files
committed
feat: bff query supports obj
1 parent 59d0531 commit bc7318a

File tree

9 files changed

+121
-49
lines changed

9 files changed

+121
-49
lines changed

.changeset/plain-rivers-design.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@modern-js/create-request': patch
3+
---
4+
5+
feat: bff query supports obj
6+
feat: bff query 支持对象类型

packages/cli/plugin-bff/src/utils/createHonoRoutes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
ValidationError,
77
isWithMetaHandler,
88
} from '@modern-js/bff-core';
9+
import { parse } from '@modern-js/create-request/qs';
910
import type { Context, Next } from '@modern-js/server-core';
1011
import typeIs from 'type-is';
1112

@@ -108,7 +109,7 @@ export const createHonoHandler = (handler: Handler) => {
108109
const getHonoInput = async (c: Context) => {
109110
const draft: Record<string, any> = {
110111
params: c.req.param(),
111-
query: c.req.query(),
112+
query: parse(c.req.query()),
112113
headers: c.req.header(),
113114
cookies: c.req.header('cookie'),
114115
};

packages/server/create-request/package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@
5454
"types": "./dist/types/node.d.ts",
5555
"jsnext:source": "./src/node.ts",
5656
"default": "./dist/cjs/node.js"
57+
},
58+
"./qs": {
59+
"types": "./dist/types/qs.d.ts",
60+
"jsnext:source": "./src/qs.ts",
61+
"default": "./dist/cjs/qs.js"
5762
}
5863
},
5964
"typesVersions": {
@@ -66,6 +71,9 @@
6671
],
6772
"server": [
6873
"./dist/types/node.d.ts"
74+
],
75+
"qs": [
76+
"./dist/types/qs.d.ts"
6977
]
7078
}
7179
},
@@ -83,7 +91,7 @@
8391
"encoding": "^0.1.13",
8492
"node-fetch": "^2.7.0",
8593
"path-to-regexp": "^6.3.0",
86-
"query-string": "^7.1.3"
94+
"qs": "^6.14.0"
8795
},
8896
"devDependencies": {
8997
"@modern-js/types": "workspace:*",
@@ -95,6 +103,7 @@
95103
"isomorphic-fetch": "^3.0.0",
96104
"jest": "^29",
97105
"nock": "^13.5.6",
106+
"@types/qs": "^6.14.0",
98107
"typescript": "^5"
99108
},
100109
"sideEffects": false,

packages/server/create-request/src/browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type Key, compile, pathToRegexp } from 'path-to-regexp';
2-
import { stringify } from 'query-string';
2+
import { stringify } from 'qs';
33
import { handleRes } from './handleRes';
44
import type {
55
BFFRequestPayload,

packages/server/create-request/src/node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { IncomingHttpHeaders } from 'http';
22
import { storage } from '@modern-js/runtime-utils/node';
33
import nodeFetch from 'node-fetch';
44
import { type Key, compile, pathToRegexp } from 'path-to-regexp';
5-
import { stringify } from 'query-string';
5+
import { stringify } from 'qs';
66
import { handleRes } from './handleRes';
77
import type {
88
BFFRequestPayload,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { stringify, parse } from 'qs';

0 commit comments

Comments
 (0)