Skip to content

Commit

Permalink
Fix types for authentication method data
Browse files Browse the repository at this point in the history
  • Loading branch information
AshMW2724 committed Dec 28, 2023
1 parent c379471 commit f644763
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/types/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { ExpressErrorResponse, HTTPContext } from './httprouter';
import { APIInfoObject } from 'documentation';
import { WebSocketServer } from 'ws';

export type CtxMiddlewareFunction<Context = {}> = (
export type CtxMiddlewareFunction<Context = {}, Data = any> = (
ctx: Context & HTTPContext,
data?: any,
data: Data,
) => (express.NextFunction | ExpressErrorResponse | void) | Promise<express.NextFunction | ExpressErrorResponse | void>;
export type MiddlewareFunction = (
req: express.Request,
Expand Down
2 changes: 1 addition & 1 deletion test/authentication/hasPermission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface Data {
where: string;
}

export const hasPermission: CtxMiddlewareFunction<Context> = (ctx, data: Data) => {
export const hasPermission: CtxMiddlewareFunction<Context, Data> = (ctx, data) => {
console.log(data.where);
return ctx.next();
};
2 changes: 1 addition & 1 deletion test/routes/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const configuration: RouteConfig = {
security: {
authentication: [
'loggedIn',
authenticationMethod('hasPermission', { penis: false }),
authenticationMethod('hasPermission', { where: 'yes' }),
{
method: 'cumInAssable',
data: 'anything',
Expand Down

0 comments on commit f644763

Please sign in to comment.