Skip to content

Commit

Permalink
fix: fun typing (#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lellansin authored Apr 20, 2020
1 parent d0cb546 commit fdf2814
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/midway-decorator/src/faas/fun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ScopeEnum, saveModule, FUNC_KEY, attachClassMetadata } from '../common'
import { KoaMiddlewareParamArray } from '..';

export interface FuncParams {
funHandler?: string;
event?: string;
method?: string;
path?: string;
Expand All @@ -15,7 +16,7 @@ export function Func(
) {
if (typeof funHandler !== 'string' && functionOptions === undefined) {
functionOptions = funHandler;
funHandler = '';
funHandler = functionOptions.funHandler;
}
return (...args) => {
const [target, key, descriptor] = args as any;
Expand Down
4 changes: 4 additions & 0 deletions packages/midway-decorator/src/faas/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ export function Handler(
funHandler: string | FuncParams,
functionOptions?: FuncParams
): MethodDecorator {
if (typeof funHandler !== 'string' && functionOptions === undefined) {
functionOptions = funHandler;
funHandler = functionOptions.funHandler;
}
return (target: object, propertykey: string, descriptor: PropertyDescriptor) => {
// If target is instance, @Func annotate class member method
saveModule(FUNC_KEY, (target as object).constructor);
Expand Down

0 comments on commit fdf2814

Please sign in to comment.