mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-18 05:09:29 +00:00
add scalar api reference
This commit is contained in:
19
src/infrastructure/common/helpers/api-schema.ts
Normal file
19
src/infrastructure/common/helpers/api-schema.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
type Constructor<T = object> = new (...args: any[]) => T
|
||||
type Wrapper<T = object> = { new (): T & any; prototype: T }
|
||||
type DecoratorOptions = { name: string }
|
||||
type ApiSchemaDecorator = <T extends Constructor>(
|
||||
options: DecoratorOptions
|
||||
) => (constructor: T) => Wrapper<T>
|
||||
|
||||
export const ApiSchema: ApiSchemaDecorator = ({ name }) => {
|
||||
return constructor => {
|
||||
const wrapper = class extends constructor {}
|
||||
|
||||
Object.defineProperty(wrapper, 'name', {
|
||||
value: name,
|
||||
writable: false,
|
||||
})
|
||||
|
||||
return wrapper
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user