Skip to content

Commit

Permalink
createDefaultResponseSchema
Browse files Browse the repository at this point in the history
  • Loading branch information
KaungWai committed Jul 27, 2023
1 parent 4896259 commit 3a6643c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/handlers/base/defaultResponse.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { TObject, TOptional, TRef, TSchema, TString, Type } from '@sinclair/typebox'
import { TObject, TRef, TSchema, Type } from '@sinclair/typebox'

export const responseMessage = Type.Union([Type.String(), Type.Undefined()], { $id: 'responseMessage' })
export const messageSchema = Type.Optional(Type.String())

type DefaultResponse<T extends TSchema = TSchema> = TObject<{
result: TRef<T>
message: TOptional<TString<string>>
message: typeof messageSchema
}>

export const createDefaultResponseSchema = <T extends TSchema = TSchema>(resultSchema: T, $id: string): DefaultResponse<T> => {
return Type.Object(
{
result: Type.Ref(resultSchema),
message: Type.Optional(Type.String()),
message: messageSchema,
},
{ $id: $id },
)
Expand Down

0 comments on commit 3a6643c

Please sign in to comment.