Skip to content

Commit

Permalink
fix(enhance): enhanceParams register
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwangchong committed Sep 5, 2023
1 parent e8d0a88 commit df0a4d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/enhance/src/context/handers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ export const enhanceQuery = (ctx: KoaContext): Context => {
return ctx as Context
}

export const enhanceParams = (ctx: Context): Context => {
export const enhanceParams = (ctx: KoaContext): Context => {
ctx.getParams = <T>(key?: string) => {
const params = Object.assign({}, ctx.getBody(), ctx.getQuery())
if (key) {
return params['key' as keyof typeof params]
}
return params as T
}
return ctx
return ctx as Context
}

/**
Expand Down
2 changes: 2 additions & 0 deletions packages/enhance/src/context/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
enhanceLogger,
enhanceQuery,
enhanceBody,
enhanceParams,
enhanceHTML,
enhanceJSON
} from './handers'
Expand All @@ -18,6 +19,7 @@ export const enhanceContext = (ctx: KoaContext): Context => {
enhanceLogger,
enhanceQuery,
enhanceBody,
enhanceParams,
enhanceHTML,
enhanceJSON
])(ctx)
Expand Down

0 comments on commit df0a4d8

Please sign in to comment.