Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Commit

Permalink
feat: Security support
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyzwezdin committed Apr 3, 2024
1 parent c153b35 commit 26ce661
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/rejs-swagger/src/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const register = (
if (isRoute(item)) {
const { metadata } = item

const { response: responseDescription, ...description } = metadata.metadata ?? {}
const { response: responseDescription, security, ...description } = metadata.metadata ?? {}

const responses: Record<number, ResponseConfig> = {}
const mimeTypes = Array.from(new Set([formatter.default.mimeType, ...Object.values(formatter.formatters).map(({ mimeType }) => mimeType)]))
Expand Down Expand Up @@ -64,6 +64,7 @@ export const register = (
: undefined,
query: metadata.schema.query,
},
security: security?.reduce<Record<string, string[]>[]>((result, current) => [...result, { [current]: [] }], []),

responses,
})
Expand Down
2 changes: 2 additions & 0 deletions packages/rejs/src/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const route = <
response?: string
deprecated?: boolean
tags?: string[]
security?: string[]
}
}): ((handler: (request: HandlerParameter, context: RequestContext) => HandlerResult) => {
metadata: {
Expand All @@ -78,6 +79,7 @@ export const route = <
response?: string
deprecated?: boolean
tags?: string[]
security?: string[]
}
}
setup: RouteSetupHandler
Expand Down
1 change: 1 addition & 0 deletions packages/rejs/src/types/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type Route<
response?: string
deprecated?: boolean
tags?: string[]
security?: string[]
}
}
setup: RouteSetupHandler
Expand Down

0 comments on commit 26ce661

Please sign in to comment.