Skip to content

Commit

Permalink
fix(express): use correct type for feathers hook context
Browse files Browse the repository at this point in the history
  • Loading branch information
vonagam committed Oct 27, 2021
1 parent 041860c commit a828798
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 0 additions & 1 deletion packages/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"@feathersjs/commons": "^5.0.0-pre.14",
"@feathersjs/errors": "^5.0.0-pre.14",
"@feathersjs/feathers": "^5.0.0-pre.14",
"@feathersjs/hooks": "^0.6.5",
"@feathersjs/transport-commons": "^5.0.0-pre.14",
"@types/express": "^4.17.13",
"@types/express-serve-static-core": "^4.17.24",
Expand Down
7 changes: 3 additions & 4 deletions packages/express/src/rest.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { MethodNotAllowed } from '@feathersjs/errors';
import { HookContext } from '@feathersjs/hooks';
import { createDebug } from '@feathersjs/commons';
import { http } from '@feathersjs/transport-commons';
import { createContext, defaultServiceMethods, getServiceOptions } from '@feathersjs/feathers';
import { HookContext, createContext, defaultServiceMethods, getServiceOptions } from '@feathersjs/feathers';
import { Request, Response, NextFunction, RequestHandler, Router } from 'express';

import { parseAuthentication } from './authentication';

const debug = createDebug('@feathersjs/express/rest');

export type ServiceCallback = (req: Request, res: Response, options: http.ServiceParams) => Promise<HookContext|any>;
export type ServiceCallback = (req: Request, res: Response, options: http.ServiceParams) => Promise<HookContext>;

export const feathersParams = (req: Request, _res: Response, next: NextFunction) => {
req.feathers = {
Expand Down Expand Up @@ -69,7 +68,7 @@ export const serviceMethodHandler = (
const args = getArgs(options);
const context = createContext(service, method);

res.hook = context as any;
res.hook = context;

return service[method](...args, context);
});
Expand Down

0 comments on commit a828798

Please # to comment.