Skip to content

Commit

Permalink
feat(router): add operations to res locals
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandryackovlev committed Dec 22, 2024
1 parent cdc5d61 commit 2ddbac0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export const createMockMiddleware = ({

router.use('/{0,}', async (req, res, next) => {
res.locals.operation = await operations.match(req);
res.locals.operations = {
...(res.locals.operations ? res.locals.operations : {}),
[spec.toString()]: operations,
};
next();
});

Expand Down
3 changes: 3 additions & 0 deletions src/operations/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export class Operation {

pathPattern: string;

path: string;

generator: JSF;

securitySchemes: { [key: string]: OpenAPIV3.SecuritySchemeObject } | null;
Expand All @@ -51,6 +53,7 @@ export class Operation {

this.method = method.toUpperCase();
this.operation = operation;
this.path = path;
this.securitySchemes = securitySchemes || null;
this.generator = generator;

Expand Down

0 comments on commit 2ddbac0

Please sign in to comment.