Skip to content

Commit

Permalink
Explicit interface NormalizedResponse.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTail committed Nov 19, 2024
1 parent 035f0e5 commit 1df5786
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/api-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const defaultStatusCodes = {

export type ResponseVariant = keyof typeof defaultStatusCodes;

/** @public this is the user facing configuration */
export interface ApiResponse<S extends z.ZodTypeAny> {
schema: S;
/** @default 200 for a positive and 400 for a negative response */
Expand All @@ -19,7 +20,12 @@ export interface ApiResponse<S extends z.ZodTypeAny> {
mimeTypes?: never;
}

export type NormalizedResponse = Pick<ApiResponse<z.ZodTypeAny>, "schema"> & {
statusCodes: Extract<ApiResponse<z.ZodTypeAny>["statusCode"], Array<unknown>>;
mimeTypes: Extract<ApiResponse<z.ZodTypeAny>["mimeType"], Array<unknown>>;
};
/**
* @private This is what the framework entities operate
* @see normalize
* */
export interface NormalizedResponse {
schema: z.ZodTypeAny;
statusCodes: [number, ...number[]];
mimeTypes: [string, ...string[]];
}

0 comments on commit 1df5786

Please sign in to comment.