Skip to content

Commit

Permalink
Feature: Add
Browse files Browse the repository at this point in the history
  • Loading branch information
SangTran-127 committed Nov 6, 2024
1 parent d78b1fe commit 2aa3bbf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
27 changes: 17 additions & 10 deletions packages/kompact-core/src/utils/extract-controller-param.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,23 @@ export const extractReqParams = (
route.methodName
);

paramMetadata?.forEach(({ index, name }: { index: number; name: string }) => {
// incase if name is undefined = @Param() params: object
args[index] = req.params[name] || req.params;
});
bodyMetadata?.forEach(
({ index, field }: { index: number; field: string }) => {
// incase if name is undefined = @Body() body: object
args[index] = req.body[field] || req.body;
}
);
if (paramMetadata) {
paramMetadata.forEach(
({ index, name }: { index: number; name: string }) => {
// incase if name is undefined = @Param() params: object
args[index] = req.params[name] || req.params;
}
);
}

if (bodyMetadata) {
bodyMetadata.forEach(
({ index, field }: { index: number; field: string }) => {
// incase if name is undefined = @Body() body: object
args[index] = req.body[field] || req.body;
}
);
}

if (Array.isArray(args) && args.length > 0) {
instanceController[route.action.name](...args, res);
Expand Down
3 changes: 2 additions & 1 deletion packages/kompact-validator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"reflect-metadata": "^0.2.2"
},
"main": "./index.cjs",
"module": "./index.js"
"module": "./index.js",
"devDependencies": {}
}

0 comments on commit 2aa3bbf

Please sign in to comment.