@aklinker1/zeta 2.1.2 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/zod-schema-adapter.d.mts +17 -0
- package/dist/adapters/zod-schema-adapter.mjs +726 -0
- package/dist/app-Bc9Kn3KA.mjs +1225 -0
- package/dist/client.d.mts +71 -0
- package/dist/client.mjs +73 -0
- package/dist/index.d.mts +317 -0
- package/dist/index.mjs +3 -0
- package/dist/schema-DKqL09oQ.d.mts +168 -0
- package/dist/schema.d.mts +2 -0
- package/dist/schema.mjs +151 -0
- package/dist/serialization-0dai2wUm.mjs +56 -0
- package/dist/testing.d.mts +26 -0
- package/dist/testing.mjs +52 -0
- package/dist/transports/bun-transport.d.mts +47 -0
- package/dist/transports/bun-transport.mjs +58 -0
- package/dist/transports/deno-transport.d.mts +48 -0
- package/dist/transports/deno-transport.mjs +57 -0
- package/dist/transports/fetch-transport.d.mts +6 -0
- package/dist/transports/fetch-transport.mjs +25 -0
- package/dist/types-BvjPE9EM.d.mts +712 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/package.json +51 -19
- package/src/adapters/zod-schema-adapter.ts +0 -29
- package/src/app.ts +0 -479
- package/src/client.ts +0 -184
- package/src/errors.ts +0 -529
- package/src/index.ts +0 -5
- package/src/internal/compile-fetch-function.ts +0 -166
- package/src/internal/compile-route-handler.ts +0 -194
- package/src/internal/context.ts +0 -65
- package/src/internal/serialization.ts +0 -91
- package/src/internal/utils.ts +0 -191
- package/src/meta.ts +0 -14
- package/src/open-api.ts +0 -273
- package/src/schema.ts +0 -271
- package/src/status.ts +0 -143
- package/src/testing.ts +0 -62
- package/src/transports/bun-transport.ts +0 -17
- package/src/transports/deno-transport.ts +0 -13
- package/src/types.ts +0 -1102
package/src/client.ts
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Main module used client-side in the same application. If you're frontend and
|
|
3
|
-
* backend are in separate projects, generate your client using the OpenAPI docs.
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import type {
|
|
7
|
-
BaseRoutes,
|
|
8
|
-
GetRequestParamsInput,
|
|
9
|
-
GetResponseOutput,
|
|
10
|
-
} from "./types";
|
|
11
|
-
import type { ErrorResponse } from "./schema";
|
|
12
|
-
import { smartDeserialize, smartSerialize } from "./internal/serialization";
|
|
13
|
-
import type {
|
|
14
|
-
GetAppRoutes,
|
|
15
|
-
App,
|
|
16
|
-
ApplyAppPrefix,
|
|
17
|
-
ApplyAppDataPrefix,
|
|
18
|
-
} from "./types";
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Type-safe client based on routes defined server-side.
|
|
22
|
-
*/
|
|
23
|
-
export interface AppClient<TRoutes extends BaseRoutes> {
|
|
24
|
-
fetch<TMethod extends keyof TRoutes, TRoute extends keyof TRoutes[TMethod]>(
|
|
25
|
-
method: TMethod,
|
|
26
|
-
route: TRoute,
|
|
27
|
-
inputs: GetRequestParamsInput<TRoutes, TMethod, TRoute>,
|
|
28
|
-
): Promise<GetResponseOutput<TRoutes, TMethod, TRoute>>;
|
|
29
|
-
fetch<TRoute extends keyof TRoutes["ANY"]>(
|
|
30
|
-
method: string,
|
|
31
|
-
route: TRoute,
|
|
32
|
-
inputs: GetRequestParamsInput<TRoutes, "ANY", TRoute>,
|
|
33
|
-
): Promise<GetResponseOutput<TRoutes, "ANY", TRoute>>;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Creates a type-safe client based on the server-side app. This is only useful
|
|
38
|
-
* if your frontend is in the same TypeScript project as your backend, and you
|
|
39
|
-
* can reference it's types in the frontend.
|
|
40
|
-
*
|
|
41
|
-
* If that's not the case, generate your client using the OpenAPI docs.
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```ts
|
|
45
|
-
* // Server-side:
|
|
46
|
-
* import { createApp } from "@aklinker1/zeta";
|
|
47
|
-
*
|
|
48
|
-
* const app = createApp();
|
|
49
|
-
* export type App = typeof app;
|
|
50
|
-
*
|
|
51
|
-
* // Client-side:
|
|
52
|
-
* import type { App } from "../server";
|
|
53
|
-
* // ^^^^ MAKE SURE TO ONLY IMPORT THE TYPE HERE
|
|
54
|
-
*
|
|
55
|
-
* const client = createAppClient<App>();
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export function createAppClient<TApp extends App>(
|
|
59
|
-
options?: CreateAppClientOptions,
|
|
60
|
-
): AppClient<GetClientRoutes<TApp>> {
|
|
61
|
-
const {
|
|
62
|
-
baseUrl = location.origin,
|
|
63
|
-
fetch = globalThis.fetch,
|
|
64
|
-
headers = {},
|
|
65
|
-
} = options ?? {};
|
|
66
|
-
|
|
67
|
-
const buildSearchParams = (query: Record<string, unknown>) => {
|
|
68
|
-
return new URLSearchParams(
|
|
69
|
-
Object.entries(query)
|
|
70
|
-
.filter(([, value]) => value != null)
|
|
71
|
-
.map(([key, value]) => [key, String(value)]),
|
|
72
|
-
).toString();
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const buildPath = (route: string, params: Record<string, unknown>) => {
|
|
76
|
-
return Object.entries(params).reduce(
|
|
77
|
-
(path, [key, value]) =>
|
|
78
|
-
path.replace(
|
|
79
|
-
key === "**" ? key : new RegExp(`\\*{2}:${key}|:${key}`),
|
|
80
|
-
encodeURIComponent(String(value)),
|
|
81
|
-
),
|
|
82
|
-
route,
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
return {
|
|
87
|
-
async fetch(method: string, route: string, inputs: any) {
|
|
88
|
-
const searchParams =
|
|
89
|
-
inputs.query == null
|
|
90
|
-
? ""
|
|
91
|
-
: `?${buildSearchParams(inputs.query).toString()}`;
|
|
92
|
-
const path =
|
|
93
|
-
inputs.params == null ? route : buildPath(route, inputs.params);
|
|
94
|
-
const url = `${join(baseUrl, path)}${searchParams}`;
|
|
95
|
-
|
|
96
|
-
const init = {
|
|
97
|
-
body: undefined as BodyInit | undefined,
|
|
98
|
-
method: (method as string).toUpperCase(),
|
|
99
|
-
headers: { ...headers } as Record<string, string>,
|
|
100
|
-
} satisfies RequestInit;
|
|
101
|
-
|
|
102
|
-
const serializedBody =
|
|
103
|
-
inputs.body == null ? undefined : smartSerialize(inputs.body);
|
|
104
|
-
if (serializedBody) {
|
|
105
|
-
init.body = serializedBody.value;
|
|
106
|
-
if (serializedBody.contentType)
|
|
107
|
-
init.headers["Content-Type"] = serializedBody.contentType;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
try {
|
|
111
|
-
const res = await fetch(url, init);
|
|
112
|
-
const response = await smartDeserialize(res);
|
|
113
|
-
if (!res.ok) {
|
|
114
|
-
throw new RequestError(
|
|
115
|
-
(response as any)?.message ?? "Unknown error",
|
|
116
|
-
res.status,
|
|
117
|
-
response as ErrorResponse,
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
return response as any;
|
|
121
|
-
} catch (err) {
|
|
122
|
-
throw Error("Fetch failed", { cause: err });
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Helper for converting an `App` to the routes it exposes.
|
|
130
|
-
*/
|
|
131
|
-
export type GetClientRoutes<TApp> =
|
|
132
|
-
TApp extends App<infer AppData>
|
|
133
|
-
? ApplyAppDataPrefix<AppData>["routes"]
|
|
134
|
-
: never;
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Thrown by the client when the response is not OK. When an `HttpError` is
|
|
138
|
-
* thrown server-side, this is the error throw client-side.
|
|
139
|
-
*/
|
|
140
|
-
export class RequestError extends Error {
|
|
141
|
-
constructor(
|
|
142
|
-
message: string,
|
|
143
|
-
public status: number,
|
|
144
|
-
public response: ErrorResponse,
|
|
145
|
-
options?: ErrorOptions,
|
|
146
|
-
) {
|
|
147
|
-
super(message, options);
|
|
148
|
-
this.name = "RequestError";
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Helper for converting an `App` type to `AppClient`.
|
|
154
|
-
*/
|
|
155
|
-
export type GetAppClient<TApp extends App> = App extends { prefix: string }
|
|
156
|
-
? GetAppClient<ApplyAppPrefix<TApp>>
|
|
157
|
-
: AppClient<
|
|
158
|
-
GetAppRoutes<TApp> extends BaseRoutes ? GetAppRoutes<TApp> : never
|
|
159
|
-
>;
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Configure the client's behavior.
|
|
163
|
-
*/
|
|
164
|
-
export type CreateAppClientOptions = {
|
|
165
|
-
fetch?: typeof fetch;
|
|
166
|
-
/**
|
|
167
|
-
* Base URL used when making requests.
|
|
168
|
-
* @default location.origin
|
|
169
|
-
*/
|
|
170
|
-
baseUrl?: string;
|
|
171
|
-
/**
|
|
172
|
-
* List of headers to send on every request.
|
|
173
|
-
* @default {}
|
|
174
|
-
*/
|
|
175
|
-
headers?: Record<string, string>;
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
/** Join string together using `/` without double slashes. */
|
|
179
|
-
function join(...paths: string[]) {
|
|
180
|
-
return paths
|
|
181
|
-
.map((path) => path.replace(/^\/+|\/+$/g, ""))
|
|
182
|
-
.filter(Boolean)
|
|
183
|
-
.join("/");
|
|
184
|
-
}
|
package/src/errors.ts
DELETED
|
@@ -1,529 +0,0 @@
|
|
|
1
|
-
import { HttpStatus } from "./status";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Base class of all HTTP errors. You can throw this error or throw any of the
|
|
5
|
-
* subclasses. Zeta will automatically detect and handle these errors, setting
|
|
6
|
-
* the appropriate status code and message.
|
|
7
|
-
*
|
|
8
|
-
* Error responses will include the stacktrace during development. To hide the
|
|
9
|
-
* stacktrace in production, set the `NODE_ENV` environment variable to
|
|
10
|
-
* `production`.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* throw new HttpError(HttpStatus.BadRequest, "Bad request")
|
|
15
|
-
* // OR
|
|
16
|
-
* throw new BadRequestError()
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export class HttpError extends Error {
|
|
20
|
-
constructor(
|
|
21
|
-
readonly status: HttpStatus,
|
|
22
|
-
message: string,
|
|
23
|
-
readonly additionalInfo?: Record<string, any>,
|
|
24
|
-
options?: ErrorOptions,
|
|
25
|
-
) {
|
|
26
|
-
super(message, options);
|
|
27
|
-
this.name = "HttpError";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** Shorthand for `new HttpError(HttpStatus.BadRequest, "Bad Request", ...)` */
|
|
32
|
-
export class BadRequestHttpError extends HttpError {
|
|
33
|
-
constructor(
|
|
34
|
-
message: string = "Bad Request",
|
|
35
|
-
additionalInfo?: Record<string, any>,
|
|
36
|
-
options?: ErrorOptions,
|
|
37
|
-
) {
|
|
38
|
-
super(HttpStatus.BadRequest, message, additionalInfo, options);
|
|
39
|
-
this.name = "BadRequestError";
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** Shorthand for `new HttpError(HttpStatus.Unauthorized, "Unauthorized", ...)` */
|
|
44
|
-
export class UnauthorizedHttpError extends HttpError {
|
|
45
|
-
constructor(
|
|
46
|
-
message: string = "Unauthorized",
|
|
47
|
-
additionalInfo?: Record<string, any>,
|
|
48
|
-
options?: ErrorOptions,
|
|
49
|
-
) {
|
|
50
|
-
super(HttpStatus.Unauthorized, message, additionalInfo, options);
|
|
51
|
-
this.name = "UnauthorizedError";
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** Shorthand for `new HttpError(HttpStatus.PaymentRequired, "Payment Required", ...)` */
|
|
56
|
-
export class PaymentRequiredHttpError extends HttpError {
|
|
57
|
-
constructor(
|
|
58
|
-
message: string = "Payment Required",
|
|
59
|
-
additionalInfo?: Record<string, any>,
|
|
60
|
-
options?: ErrorOptions,
|
|
61
|
-
) {
|
|
62
|
-
super(HttpStatus.PaymentRequired, message, additionalInfo, options);
|
|
63
|
-
this.name = "PaymentRequiredError";
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Shorthand for `new HttpError(HttpStatus.Forbidden, "Forbidden", ...)` */
|
|
68
|
-
export class ForbiddenHttpError extends HttpError {
|
|
69
|
-
constructor(
|
|
70
|
-
message: string = "Forbidden",
|
|
71
|
-
additionalInfo?: Record<string, any>,
|
|
72
|
-
options?: ErrorOptions,
|
|
73
|
-
) {
|
|
74
|
-
super(HttpStatus.Forbidden, message, additionalInfo, options);
|
|
75
|
-
this.name = "ForbiddenError";
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** Shorthand for `new HttpError(HttpStatus.NotFound, "Not Found", ...)` */
|
|
80
|
-
export class NotFoundHttpError extends HttpError {
|
|
81
|
-
constructor(
|
|
82
|
-
message: string = "Not Found",
|
|
83
|
-
additionalInfo?: Record<string, any>,
|
|
84
|
-
options?: ErrorOptions,
|
|
85
|
-
) {
|
|
86
|
-
super(HttpStatus.NotFound, message, additionalInfo, options);
|
|
87
|
-
this.name = "NotFoundHttpError";
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** Shorthand for `new HttpError(HttpStatus.MethodNotAllowed, "Method Not Allowed", ...)` */
|
|
92
|
-
export class MethodNotAllowedHttpError extends HttpError {
|
|
93
|
-
constructor(
|
|
94
|
-
message: string = "Method Not Allowed",
|
|
95
|
-
additionalInfo?: Record<string, any>,
|
|
96
|
-
options?: ErrorOptions,
|
|
97
|
-
) {
|
|
98
|
-
super(HttpStatus.MethodNotAllowed, message, additionalInfo, options);
|
|
99
|
-
this.name = "MethodNotAllowedError";
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/** Shorthand for `new HttpError(HttpStatus.NotAcceptable, "Not Acceptable", ...)` */
|
|
104
|
-
export class NotAcceptableHttpError extends HttpError {
|
|
105
|
-
constructor(
|
|
106
|
-
message: string = "Not Acceptable",
|
|
107
|
-
additionalInfo?: Record<string, any>,
|
|
108
|
-
options?: ErrorOptions,
|
|
109
|
-
) {
|
|
110
|
-
super(HttpStatus.NotAcceptable, message, additionalInfo, options);
|
|
111
|
-
this.name = "NotAcceptableError";
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/** Shorthand for `new HttpError(HttpStatus.ProxyAuthenticationRequired, "Proxy Authentication Required", ...)` */
|
|
116
|
-
export class ProxyAuthenticationRequiredHttpError extends HttpError {
|
|
117
|
-
constructor(
|
|
118
|
-
message: string = "Proxy Authentication Required",
|
|
119
|
-
additionalInfo?: Record<string, any>,
|
|
120
|
-
options?: ErrorOptions,
|
|
121
|
-
) {
|
|
122
|
-
super(
|
|
123
|
-
HttpStatus.ProxyAuthenticationRequired,
|
|
124
|
-
message,
|
|
125
|
-
additionalInfo,
|
|
126
|
-
options,
|
|
127
|
-
);
|
|
128
|
-
this.name = "ProxyAuthenticationRequiredError";
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/** Shorthand for `new HttpError(HttpStatus.RequestTimeout, "Request Timeout", ...)` */
|
|
133
|
-
export class RequestTimeoutHttpError extends HttpError {
|
|
134
|
-
constructor(
|
|
135
|
-
message: string = "Request Timeout",
|
|
136
|
-
additionalInfo?: Record<string, any>,
|
|
137
|
-
options?: ErrorOptions,
|
|
138
|
-
) {
|
|
139
|
-
super(HttpStatus.RequestTimeout, message, additionalInfo, options);
|
|
140
|
-
this.name = "RequestTimeoutError";
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/** Shorthand for `new HttpError(HttpStatus.Conflict, "Conflict", ...)` */
|
|
145
|
-
export class ConflictHttpError extends HttpError {
|
|
146
|
-
constructor(
|
|
147
|
-
message: string = "Conflict",
|
|
148
|
-
additionalInfo?: Record<string, any>,
|
|
149
|
-
options?: ErrorOptions,
|
|
150
|
-
) {
|
|
151
|
-
super(HttpStatus.Conflict, message, additionalInfo, options);
|
|
152
|
-
this.name = "ConflictError";
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/** Shorthand for `new HttpError(HttpStatus.Gone, "Gone", ...)` */
|
|
157
|
-
export class GoneHttpError extends HttpError {
|
|
158
|
-
constructor(
|
|
159
|
-
message: string = "Gone",
|
|
160
|
-
additionalInfo?: Record<string, any>,
|
|
161
|
-
options?: ErrorOptions,
|
|
162
|
-
) {
|
|
163
|
-
super(HttpStatus.Gone, message, additionalInfo, options);
|
|
164
|
-
this.name = "GoneError";
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/** Shorthand for `new HttpError(HttpStatus.LengthRequired, "Length Required", ...)` */
|
|
169
|
-
export class LengthRequiredHttpError extends HttpError {
|
|
170
|
-
constructor(
|
|
171
|
-
message: string = "Length Required",
|
|
172
|
-
additionalInfo?: Record<string, any>,
|
|
173
|
-
options?: ErrorOptions,
|
|
174
|
-
) {
|
|
175
|
-
super(HttpStatus.LengthRequired, message, additionalInfo, options);
|
|
176
|
-
this.name = "LengthRequiredError";
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/** Shorthand for `new HttpError(HttpStatus.PreconditionFailed, "Precondition Failed", ...)` */
|
|
181
|
-
export class PreconditionFailedHttpError extends HttpError {
|
|
182
|
-
constructor(
|
|
183
|
-
message: string = "Precondition Failed",
|
|
184
|
-
additionalInfo?: Record<string, any>,
|
|
185
|
-
options?: ErrorOptions,
|
|
186
|
-
) {
|
|
187
|
-
super(HttpStatus.PreconditionFailed, message, additionalInfo, options);
|
|
188
|
-
this.name = "PreconditionFailedError";
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/** Shorthand for `new HttpError(HttpStatus.ContentTooLarge, "Content Too Large", ...)` */
|
|
193
|
-
export class ContentTooLargeHttpError extends HttpError {
|
|
194
|
-
constructor(
|
|
195
|
-
message: string = "Content Too Large",
|
|
196
|
-
additionalInfo?: Record<string, any>,
|
|
197
|
-
options?: ErrorOptions,
|
|
198
|
-
) {
|
|
199
|
-
super(HttpStatus.ContentTooLarge, message, additionalInfo, options);
|
|
200
|
-
this.name = "ContentTooLargeError";
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/** Shorthand for `new HttpError(HttpStatus.UriTooLong, "URI Too Long", ...)` */
|
|
205
|
-
export class UriTooLongHttpError extends HttpError {
|
|
206
|
-
constructor(
|
|
207
|
-
message: string = "URI Too Long",
|
|
208
|
-
additionalInfo?: Record<string, any>,
|
|
209
|
-
options?: ErrorOptions,
|
|
210
|
-
) {
|
|
211
|
-
super(HttpStatus.UriTooLong, message, additionalInfo, options);
|
|
212
|
-
this.name = "UriTooLongError";
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/** Shorthand for `new HttpError(HttpStatus.UnsupportedMediaType, "Unsupported Media Type", ...)` */
|
|
217
|
-
export class UnsupportedMediaTypeHttpError extends HttpError {
|
|
218
|
-
constructor(
|
|
219
|
-
message: string = "Unsupported Media Type",
|
|
220
|
-
additionalInfo?: Record<string, any>,
|
|
221
|
-
options?: ErrorOptions,
|
|
222
|
-
) {
|
|
223
|
-
super(HttpStatus.UnsupportedMediaType, message, additionalInfo, options);
|
|
224
|
-
this.name = "UnsupportedMediaTypeError";
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/** Shorthand for `new HttpError(HttpStatus.RangeNotSatisfiable, "Range Not Satisfiable", ...)` */
|
|
229
|
-
export class RangeNotSatisfiableHttpError extends HttpError {
|
|
230
|
-
constructor(
|
|
231
|
-
message: string = "Range Not Satisfiable",
|
|
232
|
-
additionalInfo?: Record<string, any>,
|
|
233
|
-
options?: ErrorOptions,
|
|
234
|
-
) {
|
|
235
|
-
super(HttpStatus.RangeNotSatisfiable, message, additionalInfo, options);
|
|
236
|
-
this.name = "RangeNotSatisfiableError";
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/** Shorthand for `new HttpError(HttpStatus.ExpectationFailed, "Expectation Failed", ...)` */
|
|
241
|
-
export class ExpectationFailedHttpError extends HttpError {
|
|
242
|
-
constructor(
|
|
243
|
-
message: string = "Expectation Failed",
|
|
244
|
-
additionalInfo?: Record<string, any>,
|
|
245
|
-
options?: ErrorOptions,
|
|
246
|
-
) {
|
|
247
|
-
super(HttpStatus.ExpectationFailed, message, additionalInfo, options);
|
|
248
|
-
this.name = "ExpectationFailedError";
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/** Shorthand for `new HttpError(HttpStatus.ImATeapot, "I'm a Teapot", ...)` */
|
|
253
|
-
export class ImATeapotHttpError extends HttpError {
|
|
254
|
-
constructor(
|
|
255
|
-
message: string = "I'm a Teapot",
|
|
256
|
-
additionalInfo?: Record<string, any>,
|
|
257
|
-
options?: ErrorOptions,
|
|
258
|
-
) {
|
|
259
|
-
super(HttpStatus.ImATeapot, message, additionalInfo, options);
|
|
260
|
-
this.name = "ImATeapotError";
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/** Shorthand for `new HttpError(HttpStatus.MisdirectedRequest, "Misdirected Request", ...)` */
|
|
265
|
-
export class MisdirectedRequestHttpError extends HttpError {
|
|
266
|
-
constructor(
|
|
267
|
-
message: string = "Misdirected Request",
|
|
268
|
-
additionalInfo?: Record<string, any>,
|
|
269
|
-
options?: ErrorOptions,
|
|
270
|
-
) {
|
|
271
|
-
super(HttpStatus.MisdirectedRequest, message, additionalInfo, options);
|
|
272
|
-
this.name = "MisdirectedRequestError";
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/** Shorthand for `new HttpError(HttpStatus.UnprocessableEntity, "Unprocessable Entity", ...)` */
|
|
277
|
-
export class UnprocessableEntityHttpError extends HttpError {
|
|
278
|
-
constructor(
|
|
279
|
-
message: string = "Unprocessable Entity",
|
|
280
|
-
additionalInfo?: Record<string, any>,
|
|
281
|
-
options?: ErrorOptions,
|
|
282
|
-
) {
|
|
283
|
-
super(HttpStatus.UnprocessableEntity, message, additionalInfo, options);
|
|
284
|
-
this.name = "UnprocessableEntityError";
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/** Shorthand for `new HttpError(HttpStatus.Locked, "Locked", ...)` */
|
|
289
|
-
export class LockedHttpError extends HttpError {
|
|
290
|
-
constructor(
|
|
291
|
-
message: string = "Locked",
|
|
292
|
-
additionalInfo?: Record<string, any>,
|
|
293
|
-
options?: ErrorOptions,
|
|
294
|
-
) {
|
|
295
|
-
super(HttpStatus.Locked, message, additionalInfo, options);
|
|
296
|
-
this.name = "LockedError";
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/** Shorthand for `new HttpError(HttpStatus.FailedDependency, "Failed Dependency", ...)` */
|
|
301
|
-
export class FailedDependencyHttpError extends HttpError {
|
|
302
|
-
constructor(
|
|
303
|
-
message: string = "Failed Dependency",
|
|
304
|
-
additionalInfo?: Record<string, any>,
|
|
305
|
-
options?: ErrorOptions,
|
|
306
|
-
) {
|
|
307
|
-
super(HttpStatus.FailedDependency, message, additionalInfo, options);
|
|
308
|
-
this.name = "FailedDependencyError";
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/** Shorthand for `new HttpError(HttpStatus.TooEarly, "Too Early", ...)` */
|
|
313
|
-
export class TooEarlyHttpError extends HttpError {
|
|
314
|
-
constructor(
|
|
315
|
-
message: string = "Too Early",
|
|
316
|
-
additionalInfo?: Record<string, any>,
|
|
317
|
-
options?: ErrorOptions,
|
|
318
|
-
) {
|
|
319
|
-
super(HttpStatus.TooEarly, message, additionalInfo, options);
|
|
320
|
-
this.name = "TooEarlyError";
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/** Shorthand for `new HttpError(HttpStatus.UpgradeRequired, "Upgrade Required", ...)` */
|
|
325
|
-
export class UpgradeRequiredHttpError extends HttpError {
|
|
326
|
-
constructor(
|
|
327
|
-
message: string = "Upgrade Required",
|
|
328
|
-
additionalInfo?: Record<string, any>,
|
|
329
|
-
options?: ErrorOptions,
|
|
330
|
-
) {
|
|
331
|
-
super(HttpStatus.UpgradeRequired, message, additionalInfo, options);
|
|
332
|
-
this.name = "UpgradeRequiredError";
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/** Shorthand for `new HttpError(HttpStatus.PreconditionRequired, "Precondition Required", ...)` */
|
|
337
|
-
export class PreconditionRequiredHttpError extends HttpError {
|
|
338
|
-
constructor(
|
|
339
|
-
message: string = "Precondition Required",
|
|
340
|
-
additionalInfo?: Record<string, any>,
|
|
341
|
-
options?: ErrorOptions,
|
|
342
|
-
) {
|
|
343
|
-
super(HttpStatus.PreconditionRequired, message, additionalInfo, options);
|
|
344
|
-
this.name = "PreconditionRequiredError";
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
/** Shorthand for `new HttpError(HttpStatus.TooManyRequests, "Too Many Requests", ...)` */
|
|
349
|
-
export class TooManyRequestsHttpError extends HttpError {
|
|
350
|
-
constructor(
|
|
351
|
-
message: string = "Too Many Requests",
|
|
352
|
-
additionalInfo?: Record<string, any>,
|
|
353
|
-
options?: ErrorOptions,
|
|
354
|
-
) {
|
|
355
|
-
super(HttpStatus.TooManyRequests, message, additionalInfo, options);
|
|
356
|
-
this.name = "TooManyRequestsError";
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
/** Shorthand for `new HttpError(HttpStatus.RequestHeaderFieldsTooLarge, "Request Header Fields Too Large", ...)` */
|
|
361
|
-
export class RequestHeaderFieldsTooLargeHttpError extends HttpError {
|
|
362
|
-
constructor(
|
|
363
|
-
message: string = "Request Header Fields Too Large",
|
|
364
|
-
additionalInfo?: Record<string, any>,
|
|
365
|
-
options?: ErrorOptions,
|
|
366
|
-
) {
|
|
367
|
-
super(
|
|
368
|
-
HttpStatus.RequestHeaderFieldsTooLarge,
|
|
369
|
-
message,
|
|
370
|
-
additionalInfo,
|
|
371
|
-
options,
|
|
372
|
-
);
|
|
373
|
-
this.name = "RequestHeaderFieldsTooLargeError";
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/** Shorthand for `new HttpError(HttpStatus.UnavailableForLegalReasons, "Unavailable For Legal Reasons", ...)` */
|
|
378
|
-
export class UnavailableForLegalReasonsHttpError extends HttpError {
|
|
379
|
-
constructor(
|
|
380
|
-
message: string = "Unavailable For Legal Reasons",
|
|
381
|
-
additionalInfo?: Record<string, any>,
|
|
382
|
-
options?: ErrorOptions,
|
|
383
|
-
) {
|
|
384
|
-
super(
|
|
385
|
-
HttpStatus.UnavailableForLegalReasons,
|
|
386
|
-
message,
|
|
387
|
-
additionalInfo,
|
|
388
|
-
options,
|
|
389
|
-
);
|
|
390
|
-
this.name = "UnavailableForLegalReasonsError";
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/** Shorthand for `new HttpError(HttpStatus.InternalServerError, "Internal Server Error", ...)` */
|
|
395
|
-
export class InternalServerErrorHttpError extends HttpError {
|
|
396
|
-
constructor(
|
|
397
|
-
message: string = "Internal Server Error",
|
|
398
|
-
additionalInfo?: Record<string, any>,
|
|
399
|
-
options?: ErrorOptions,
|
|
400
|
-
) {
|
|
401
|
-
super(HttpStatus.InternalServerError, message, additionalInfo, options);
|
|
402
|
-
this.name = "InternalServerErrorError";
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/** Shorthand for `new HttpError(HttpStatus.NotImplemented, "Not Implemented", ...)` */
|
|
407
|
-
export class NotImplementedHttpError extends HttpError {
|
|
408
|
-
constructor(
|
|
409
|
-
message: string = "Not Implemented",
|
|
410
|
-
additionalInfo?: Record<string, any>,
|
|
411
|
-
options?: ErrorOptions,
|
|
412
|
-
) {
|
|
413
|
-
super(HttpStatus.NotImplemented, message, additionalInfo, options);
|
|
414
|
-
this.name = "NotImplementedHttpError";
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/** Shorthand for `new HttpError(HttpStatus.BadGateway, "Bad Gateway", ...)` */
|
|
419
|
-
export class BadGatewayHttpError extends HttpError {
|
|
420
|
-
constructor(
|
|
421
|
-
message: string = "Bad Gateway",
|
|
422
|
-
additionalInfo?: Record<string, any>,
|
|
423
|
-
options?: ErrorOptions,
|
|
424
|
-
) {
|
|
425
|
-
super(HttpStatus.BadGateway, message, additionalInfo, options);
|
|
426
|
-
this.name = "BadGatewayError";
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
/** Shorthand for `new HttpError(HttpStatus.ServiceUnavailable, "Service Unavailable", ...)` */
|
|
431
|
-
export class ServiceUnavailableHttpError extends HttpError {
|
|
432
|
-
constructor(
|
|
433
|
-
message: string = "Service Unavailable",
|
|
434
|
-
additionalInfo?: Record<string, any>,
|
|
435
|
-
options?: ErrorOptions,
|
|
436
|
-
) {
|
|
437
|
-
super(HttpStatus.ServiceUnavailable, message, additionalInfo, options);
|
|
438
|
-
this.name = "ServiceUnavailableError";
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
/** Shorthand for `new HttpError(HttpStatus.GatewayTimeout, "Gateway Timeout", ...)` */
|
|
443
|
-
export class GatewayTimeoutHttpError extends HttpError {
|
|
444
|
-
constructor(
|
|
445
|
-
message: string = "Gateway Timeout",
|
|
446
|
-
additionalInfo?: Record<string, any>,
|
|
447
|
-
options?: ErrorOptions,
|
|
448
|
-
) {
|
|
449
|
-
super(HttpStatus.GatewayTimeout, message, additionalInfo, options);
|
|
450
|
-
this.name = "GatewayTimeoutError";
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
/** Shorthand for `new HttpError(HttpStatus.HttpVersionNotSupported, "HTTP Version Not Supported", ...)` */
|
|
455
|
-
export class HttpVersionNotSupportedHttpError extends HttpError {
|
|
456
|
-
constructor(
|
|
457
|
-
message: string = "HTTP Version Not Supported",
|
|
458
|
-
additionalInfo?: Record<string, any>,
|
|
459
|
-
options?: ErrorOptions,
|
|
460
|
-
) {
|
|
461
|
-
super(HttpStatus.HttpVersionNotSupported, message, additionalInfo, options);
|
|
462
|
-
this.name = "HttpVersionNotSupportedError";
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/** Shorthand for `new HttpError(HttpStatus.VariantAlsoNegotiates, "Variant Also Negotiates", ...)` */
|
|
467
|
-
export class VariantAlsoNegotiatesHttpError extends HttpError {
|
|
468
|
-
constructor(
|
|
469
|
-
message: string = "Variant Also Negotiates",
|
|
470
|
-
additionalInfo?: Record<string, any>,
|
|
471
|
-
options?: ErrorOptions,
|
|
472
|
-
) {
|
|
473
|
-
super(HttpStatus.VariantAlsoNegotiates, message, additionalInfo, options);
|
|
474
|
-
this.name = "VariantAlsoNegotiatesError";
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
/** Shorthand for `new HttpError(HttpStatus.InsufficientStorage, "Insufficient Storage", ...)` */
|
|
479
|
-
export class InsufficientStorageHttpError extends HttpError {
|
|
480
|
-
constructor(
|
|
481
|
-
message: string = "Insufficient Storage",
|
|
482
|
-
additionalInfo?: Record<string, any>,
|
|
483
|
-
options?: ErrorOptions,
|
|
484
|
-
) {
|
|
485
|
-
super(HttpStatus.InsufficientStorage, message, additionalInfo, options);
|
|
486
|
-
this.name = "InsufficientStorageError";
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
/** Shorthand for `new HttpError(HttpStatus.LoopDetected, "Loop Detected", ...)` */
|
|
491
|
-
export class LoopDetectedHttpError extends HttpError {
|
|
492
|
-
constructor(
|
|
493
|
-
message: string = "Loop Detected",
|
|
494
|
-
additionalInfo?: Record<string, any>,
|
|
495
|
-
options?: ErrorOptions,
|
|
496
|
-
) {
|
|
497
|
-
super(HttpStatus.LoopDetected, message, additionalInfo, options);
|
|
498
|
-
this.name = "LoopDetectedError";
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
/** Shorthand for `new HttpError(HttpStatus.NotExtended, "Not Extended", ...)` */
|
|
503
|
-
export class NotExtendedHttpError extends HttpError {
|
|
504
|
-
constructor(
|
|
505
|
-
message: string = "Not Extended",
|
|
506
|
-
additionalInfo?: Record<string, any>,
|
|
507
|
-
options?: ErrorOptions,
|
|
508
|
-
) {
|
|
509
|
-
super(HttpStatus.NotExtended, message, additionalInfo, options);
|
|
510
|
-
this.name = "NotExtendedError";
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
/** Shorthand for `new HttpError(HttpStatus.NetworkAuthenticationRequired, "Network Authentication Required", ...)` */
|
|
515
|
-
export class NetworkAuthenticationRequiredHttpError extends HttpError {
|
|
516
|
-
constructor(
|
|
517
|
-
message: string = "Network Authentication Required",
|
|
518
|
-
additionalInfo?: Record<string, any>,
|
|
519
|
-
options?: ErrorOptions,
|
|
520
|
-
) {
|
|
521
|
-
super(
|
|
522
|
-
HttpStatus.NetworkAuthenticationRequired,
|
|
523
|
-
message,
|
|
524
|
-
additionalInfo,
|
|
525
|
-
options,
|
|
526
|
-
);
|
|
527
|
-
this.name = "NetworkAuthenticationRequiredError";
|
|
528
|
-
}
|
|
529
|
-
}
|