Skip to content

Commit c967ce4

Browse files
committed
1.3.7
1 parent 3478790 commit c967ce4

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@grandlinex/kernel",
3-
"version": "1.3.6",
3+
"version": "1.3.7",
44
"description": "GrandLineX is an out-of-the-box server framework on top of ExpressJs.",
55
"type": "module",
66
"exports": {

src/classes/BaseAction.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ import {
2222
} from '../lib/index.js';
2323
import { ExpressServerTiming, IExtensionInterface } from './timing/index.js';
2424

25-
import { XActionEvent, XRequest, XResponse } from '../lib/express.js';
25+
import {
26+
XActionEvent,
27+
XPath,
28+
XQuery,
29+
XRequest,
30+
XResponse,
31+
} from '../lib/express.js';
2632
import { BaseUserAgent } from './BaseUserAgent.js';
2733

2834
export default abstract class BaseAction<
@@ -175,6 +181,18 @@ export default abstract class BaseAction<
175181
res: XResponse,
176182
next: () => void,
177183
): Promise<void> {
184+
const xPath: XPath = {};
185+
Object.entries(req.params).forEach(([k, v]) => {
186+
if (typeof v === 'string') {
187+
xPath[k] = v;
188+
}
189+
});
190+
const xQuery: XQuery = {};
191+
Object.entries(req.query).forEach(([k, v]) => {
192+
if (typeof v === 'string' || v === undefined) {
193+
xQuery[k] = v;
194+
}
195+
});
178196
const extension = this.initExtension(res);
179197
const auth = extension.timing.start('auth');
180198
res.on('finish', () => {
@@ -213,6 +231,8 @@ export default abstract class BaseAction<
213231
extension,
214232
agent: new BaseUserAgent(req),
215233
body,
234+
path: xPath,
235+
query: xQuery,
216236
sendError: (code: number, error: Partial<ErrorType>) =>
217237
BaseAction.sendError(res, code, error),
218238
});
@@ -250,6 +270,8 @@ export default abstract class BaseAction<
250270
extension,
251271
agent: new BaseUserAgent(req),
252272
body,
273+
path: xPath,
274+
query: xQuery,
253275
sendError: (code: number, error: Partial<ErrorType>) =>
254276
BaseAction.sendError(res, code, error),
255277
});
@@ -283,6 +305,8 @@ export default abstract class BaseAction<
283305
extension,
284306
agent: new BaseUserAgent(req),
285307
body,
308+
path: xPath,
309+
query: xQuery,
286310
sendError: (code: number, error: Partial<ErrorType>) =>
287311
BaseAction.sendError(res, code, error),
288312
});

src/lib/express.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ export type XRequest = express.Request & {
1212
export type XResponse = express.Response;
1313
export type XNextFc = express.NextFunction;
1414

15+
export type XPath = Record<string, string>;
16+
export type XQuery = Record<string, string | undefined>;
17+
1518
export type XActionEvent<G = JwtToken | null, B = any> = {
1619
req: XRequest;
1720
res: XResponse;
1821
next: XNextFc;
1922
data: G;
23+
path: XPath;
24+
query: XQuery;
2025
extension: IExtensionInterface;
2126
agent: BaseUserAgent;
2227
body: B;

0 commit comments

Comments
 (0)