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

RobinTail / express-zod-api / 13444086320

20 Feb 2025 08:28PM UTC coverage: 100.0%. First build
13444086320

Pull #2425

github

web-flow
Merge 60a537c42 into 23732b2fe
Pull Request #2425: Fix: async `errorHandler` for not found case

1253 of 1279 branches covered (97.97%)

1 of 1 new or added line in 1 file covered. (100.0%)

4223 of 4223 relevant lines covered (100.0%)

210.05 hits per line

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

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

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

8
export type ResponseVariant = keyof typeof defaultStatusCodes;
9
export const responseVariants = Object.keys(
4✔
10
  defaultStatusCodes,
4✔
11
) as ResponseVariant[];
4✔
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