• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

RobinTail / express-zod-api / 12826049652

17 Jan 2025 09:12AM UTC coverage: 100.0%. Remained the same
12826049652

Pull #2320

github

web-flow
Merge 73690bc24 into 66d73ec52
Pull Request #2320: Removing HTTP Errors comparator (Vitest 3)

1215 of 1237 branches covered (98.22%)

4357 of 4357 relevant lines covered (100.0%)

366.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/api-response.ts
1
import { z } from "zod";
2

3
export const defaultStatusCodes = {
6✔
4
  positive: 200,
6✔
5
  negative: 400,
6✔
6
} satisfies Record<string, number>;
6✔
7

8
export type ResponseVariant = keyof typeof defaultStatusCodes;
9
export const responseVariants = Object.keys(
6✔
10
  defaultStatusCodes,
6✔
11
) as ResponseVariant[];
6✔
12

13
/** @public this is the user facing configuration */
14
export interface ApiResponse<S extends z.ZodTypeAny> {
15
  schema: S;
16
  /** @default 200 for a positive and 400 for a negative response */
17
  statusCode?: number | [number, ...number[]];
18
  /**
19
   * @example null is for no content, such as 204 and 302
20
   * @default "application/json"
21
   * */
22
  mimeType?: string | [string, ...string[]] | null;
23
  /** @deprecated use statusCode */
24
  statusCodes?: never;
25
  /** @deprecated use mimeType */
26
  mimeTypes?: never;
27
}
28

29
/**
30
 * @private This is what the framework entities operate
31
 * @see normalize
32
 * */
33
export interface NormalizedResponse {
34
  schema: z.ZodTypeAny;
35
  statusCodes: [number, ...number[]];
36
  mimeTypes: [string, ...string[]] | null;
37
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc