@aklinker1/zeta 2.1.1 → 2.1.3
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/client.d.mts +71 -0
- package/dist/client.mjs +73 -0
- package/dist/index.d.mts +316 -0
- package/dist/index.mjs +1236 -0
- package/dist/schema-IKHh0I39.d.mts +168 -0
- package/dist/schema.d.mts +2 -0
- package/dist/schema.mjs +151 -0
- package/dist/serialization-C8e7ECQ2.mjs +56 -0
- package/dist/testing.d.mts +26 -0
- package/dist/testing.mjs +52 -0
- package/dist/transports/bun-transport.d.mts +7 -0
- package/dist/transports/bun-transport.mjs +14 -0
- package/dist/transports/deno-transport.d.mts +6 -0
- package/dist/transports/deno-transport.mjs +13 -0
- package/dist/types-D9oRVe1E.d.mts +698 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/package.json +39 -17
- 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
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { t as ErrorResponse } from "./schema-IKHh0I39.mjs";
|
|
2
|
+
import { _ as GetAppRoutes, d as BaseRoutes, i as App, o as ApplyAppDataPrefix, s as ApplyAppPrefix, v as GetRequestParamsInput, w as GetResponseOutput } from "./types-D9oRVe1E.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/client.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Type-safe client based on routes defined server-side.
|
|
7
|
+
*/
|
|
8
|
+
interface AppClient<TRoutes extends BaseRoutes> {
|
|
9
|
+
fetch<TMethod extends keyof TRoutes, TRoute extends keyof TRoutes[TMethod]>(method: TMethod, route: TRoute, inputs: GetRequestParamsInput<TRoutes, TMethod, TRoute>): Promise<GetResponseOutput<TRoutes, TMethod, TRoute>>;
|
|
10
|
+
fetch<TRoute extends keyof TRoutes["ANY"]>(method: string, route: TRoute, inputs: GetRequestParamsInput<TRoutes, "ANY", TRoute>): Promise<GetResponseOutput<TRoutes, "ANY", TRoute>>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates a type-safe client based on the server-side app. This is only useful
|
|
14
|
+
* if your frontend is in the same TypeScript project as your backend, and you
|
|
15
|
+
* can reference it's types in the frontend.
|
|
16
|
+
*
|
|
17
|
+
* If that's not the case, generate your client using the OpenAPI docs.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* // Server-side:
|
|
22
|
+
* import { createApp } from "@aklinker1/zeta";
|
|
23
|
+
*
|
|
24
|
+
* const app = createApp();
|
|
25
|
+
* export type App = typeof app;
|
|
26
|
+
*
|
|
27
|
+
* // Client-side:
|
|
28
|
+
* import type { App } from "../server";
|
|
29
|
+
* // ^^^^ MAKE SURE TO ONLY IMPORT THE TYPE HERE
|
|
30
|
+
*
|
|
31
|
+
* const client = createAppClient<App>();
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
declare function createAppClient<TApp extends App>(options?: CreateAppClientOptions): AppClient<GetClientRoutes<TApp>>;
|
|
35
|
+
/**
|
|
36
|
+
* Helper for converting an `App` to the routes it exposes.
|
|
37
|
+
*/
|
|
38
|
+
type GetClientRoutes<TApp> = TApp extends App<infer AppData> ? ApplyAppDataPrefix<AppData>["routes"] : never;
|
|
39
|
+
/**
|
|
40
|
+
* Thrown by the client when the response is not OK. When an `HttpError` is
|
|
41
|
+
* thrown server-side, this is the error throw client-side.
|
|
42
|
+
*/
|
|
43
|
+
declare class RequestError extends Error {
|
|
44
|
+
status: number;
|
|
45
|
+
response: ErrorResponse;
|
|
46
|
+
constructor(message: string, status: number, response: ErrorResponse, options?: ErrorOptions);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Helper for converting an `App` type to `AppClient`.
|
|
50
|
+
*/
|
|
51
|
+
type GetAppClient<TApp extends App> = App extends {
|
|
52
|
+
prefix: string;
|
|
53
|
+
} ? GetAppClient<ApplyAppPrefix<TApp>> : AppClient<GetAppRoutes<TApp> extends BaseRoutes ? GetAppRoutes<TApp> : never>;
|
|
54
|
+
/**
|
|
55
|
+
* Configure the client's behavior.
|
|
56
|
+
*/
|
|
57
|
+
type CreateAppClientOptions = {
|
|
58
|
+
fetch?: typeof fetch;
|
|
59
|
+
/**
|
|
60
|
+
* Base URL used when making requests.
|
|
61
|
+
* @default location.origin
|
|
62
|
+
*/
|
|
63
|
+
baseUrl?: string;
|
|
64
|
+
/**
|
|
65
|
+
* List of headers to send on every request.
|
|
66
|
+
* @default {}
|
|
67
|
+
*/
|
|
68
|
+
headers?: Record<string, string>;
|
|
69
|
+
};
|
|
70
|
+
//#endregion
|
|
71
|
+
export { AppClient, CreateAppClientOptions, GetAppClient, GetClientRoutes, RequestError, createAppClient };
|
package/dist/client.mjs
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { n as smartSerialize, t as smartDeserialize } from "./serialization-C8e7ECQ2.mjs";
|
|
2
|
+
//#region src/client.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a type-safe client based on the server-side app. This is only useful
|
|
5
|
+
* if your frontend is in the same TypeScript project as your backend, and you
|
|
6
|
+
* can reference it's types in the frontend.
|
|
7
|
+
*
|
|
8
|
+
* If that's not the case, generate your client using the OpenAPI docs.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // Server-side:
|
|
13
|
+
* import { createApp } from "@aklinker1/zeta";
|
|
14
|
+
*
|
|
15
|
+
* const app = createApp();
|
|
16
|
+
* export type App = typeof app;
|
|
17
|
+
*
|
|
18
|
+
* // Client-side:
|
|
19
|
+
* import type { App } from "../server";
|
|
20
|
+
* // ^^^^ MAKE SURE TO ONLY IMPORT THE TYPE HERE
|
|
21
|
+
*
|
|
22
|
+
* const client = createAppClient<App>();
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
function createAppClient(options) {
|
|
26
|
+
const { baseUrl = location.origin, fetch = globalThis.fetch, headers = {} } = options ?? {};
|
|
27
|
+
const buildSearchParams = (query) => {
|
|
28
|
+
return new URLSearchParams(Object.entries(query).filter(([, value]) => value != null).map(([key, value]) => [key, String(value)])).toString();
|
|
29
|
+
};
|
|
30
|
+
const buildPath = (route, params) => {
|
|
31
|
+
return Object.entries(params).reduce((path, [key, value]) => path.replace(key === "**" ? key : new RegExp(`\\*{2}:${key}|:${key}`), encodeURIComponent(String(value))), route);
|
|
32
|
+
};
|
|
33
|
+
return { async fetch(method, route, inputs) {
|
|
34
|
+
const searchParams = inputs.query == null ? "" : `?${buildSearchParams(inputs.query).toString()}`;
|
|
35
|
+
const url = `${join(baseUrl, inputs.params == null ? route : buildPath(route, inputs.params))}${searchParams}`;
|
|
36
|
+
const init = {
|
|
37
|
+
body: void 0,
|
|
38
|
+
method: method.toUpperCase(),
|
|
39
|
+
headers: { ...headers }
|
|
40
|
+
};
|
|
41
|
+
const serializedBody = inputs.body == null ? void 0 : smartSerialize(inputs.body);
|
|
42
|
+
if (serializedBody) {
|
|
43
|
+
init.body = serializedBody.value;
|
|
44
|
+
if (serializedBody.contentType) init.headers["Content-Type"] = serializedBody.contentType;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const res = await fetch(url, init);
|
|
48
|
+
const response = await smartDeserialize(res);
|
|
49
|
+
if (!res.ok) throw new RequestError(response?.message ?? "Unknown error", res.status, response);
|
|
50
|
+
return response;
|
|
51
|
+
} catch (err) {
|
|
52
|
+
throw Error("Fetch failed", { cause: err });
|
|
53
|
+
}
|
|
54
|
+
} };
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Thrown by the client when the response is not OK. When an `HttpError` is
|
|
58
|
+
* thrown server-side, this is the error throw client-side.
|
|
59
|
+
*/
|
|
60
|
+
var RequestError = class extends Error {
|
|
61
|
+
constructor(message, status, response, options) {
|
|
62
|
+
super(message, options);
|
|
63
|
+
this.status = status;
|
|
64
|
+
this.response = response;
|
|
65
|
+
this.name = "RequestError";
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
/** Join string together using `/` without double slashes. */
|
|
69
|
+
function join(...paths) {
|
|
70
|
+
return paths.map((path) => path.replace(/^\/+|\/+$/g, "")).filter(Boolean).join("/");
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
export { RequestError, createAppClient };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { i as NoResponse, l as HttpStatus, s as ZetaSchema, t as ErrorResponse, u as getHttpStatusName } from "./schema-IKHh0I39.mjs";
|
|
2
|
+
import { $ as SchemaAdapter, at as Transport, i as App, l as BasePath, u as BasePrefix } from "./types-D9oRVe1E.mjs";
|
|
3
|
+
import { OpenAPI, OpenAPIV3_1 } from "openapi-types";
|
|
4
|
+
|
|
5
|
+
//#region src/app.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Create a server-side, Zeta application.
|
|
8
|
+
*
|
|
9
|
+
* Zeta provides simple support for serving applications using `Bun.serve` and
|
|
10
|
+
* `Deno.serve` by calling `app.listen(3000)`.
|
|
11
|
+
*
|
|
12
|
+
* If you need more customization, you can use the `build` method to create a
|
|
13
|
+
* `fetch` function and serve it however you like.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { createApp } from "@aklinker1/zeta";
|
|
18
|
+
*
|
|
19
|
+
* const app = createApp({ prefix: "/api" })
|
|
20
|
+
* .get("/health", () => "OK")
|
|
21
|
+
* .get("/users", () => ["user1", "user2"]);
|
|
22
|
+
*
|
|
23
|
+
* app.listen(3000);
|
|
24
|
+
*
|
|
25
|
+
* // Or serve the app yourself
|
|
26
|
+
* const fetch = app.build();
|
|
27
|
+
* Bun.serve({ fetch, ... });
|
|
28
|
+
* Deno.serve({ fetch, ... });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param options Configure application behavior.
|
|
32
|
+
*/
|
|
33
|
+
declare function createApp<TPrefix extends BasePrefix = "">(options?: CreateAppOptions<TPrefix>): App<{
|
|
34
|
+
ctx: {};
|
|
35
|
+
exported: false;
|
|
36
|
+
prefix: TPrefix;
|
|
37
|
+
routes: {};
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Configure how the app is created.
|
|
41
|
+
*/
|
|
42
|
+
type CreateAppOptions<TPrefix extends BasePrefix = ""> = {
|
|
43
|
+
/**
|
|
44
|
+
* The origin to use when constructing URLs.
|
|
45
|
+
* @default "http://localhost"
|
|
46
|
+
*/
|
|
47
|
+
origin?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Add a prefix to the beginning of all routes in the app.
|
|
50
|
+
*/
|
|
51
|
+
prefix?: TPrefix;
|
|
52
|
+
/**
|
|
53
|
+
* Tell Zeta which library you're using for validation. OpenAPI docs cannot
|
|
54
|
+
* be served without a schema adapter.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { zodSchemaAdapter } from "@aklinker1/zeta/adapters/zod-schema-adapter"
|
|
59
|
+
*
|
|
60
|
+
* const app = createApp({
|
|
61
|
+
* openApi: {
|
|
62
|
+
* schemaAdapter: zodSchemaAdapter,
|
|
63
|
+
* },
|
|
64
|
+
* });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
schemaAdapter?: SchemaAdapter;
|
|
68
|
+
/**
|
|
69
|
+
* Tell Zeta how to serve your app over a port. By default, Zeta will detect
|
|
70
|
+
* if you're runtime is Bun or Deno, and use the appropriate transport.
|
|
71
|
+
*
|
|
72
|
+
* If you need to customize the transport, like adding an `idleTimeout` to
|
|
73
|
+
* bun, you can do so by passing options into the transport's factory function.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { createBunTransport } from "@aklinker1/zeta/transports/bun-transport"
|
|
78
|
+
*
|
|
79
|
+
* const app = createApp({
|
|
80
|
+
* transport: createBunTransport(),
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
transport?: Transport;
|
|
85
|
+
/**
|
|
86
|
+
* Where the OpenAPI JSON docs is hosted.
|
|
87
|
+
* @default "/openapi.json"
|
|
88
|
+
*/
|
|
89
|
+
openApiRoute?: BasePath;
|
|
90
|
+
/**
|
|
91
|
+
* Where the Scalar UI is hosted.
|
|
92
|
+
* @default "/scalar"
|
|
93
|
+
*/
|
|
94
|
+
scalarRoute?: BasePath; /** Configure how your application's OpenAPI docs are generated. */
|
|
95
|
+
openApi?: Partial<OpenAPIV3_1.Document> & {};
|
|
96
|
+
/**
|
|
97
|
+
* OpenAPI tags to apply to all routes in this app. Route-level tags will
|
|
98
|
+
* override these app-level tags.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* const usersApp = createApp({
|
|
103
|
+
* prefix: "/users",
|
|
104
|
+
* tags: ["Users"],
|
|
105
|
+
* })
|
|
106
|
+
* .get("/", {}, () => [...]) // Will have ["Users"] tag
|
|
107
|
+
* .get("/:id", { tags: ["Admin"] }, () => {...}) // Will have ["Admin"] tag (overrides app-level)
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
tags?: string[];
|
|
111
|
+
/**
|
|
112
|
+
* OpenAPI security requirements to apply to all routes in this app.
|
|
113
|
+
* Route-level security will override these app-level security requirements.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* const authApp = createApp({
|
|
118
|
+
* prefix: "/auth",
|
|
119
|
+
* security: [{ bearerAuth: [] }],
|
|
120
|
+
* })
|
|
121
|
+
* .get("/profile", {}, () => {...}) // Will require bearerAuth
|
|
122
|
+
* .get("/admin", { security: [{ adminKey: [] }] }, () => {...}) // Will require adminKey (overrides app-level)
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
security?: OpenAPI.Document["security"];
|
|
126
|
+
/**
|
|
127
|
+
* Configure [Scalar](https://scalar.com/) UI docs.
|
|
128
|
+
* @see https://github.com/scalar/scalar/blob/main/documentation/configuration.md#list-of-all-attributes
|
|
129
|
+
*/
|
|
130
|
+
scalar?: any;
|
|
131
|
+
};
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/errors.d.ts
|
|
134
|
+
/**
|
|
135
|
+
* Base class of all HTTP errors. You can throw this error or throw any of the
|
|
136
|
+
* subclasses. Zeta will automatically detect and handle these errors, setting
|
|
137
|
+
* the appropriate status code and message.
|
|
138
|
+
*
|
|
139
|
+
* Error responses will include the stacktrace during development. To hide the
|
|
140
|
+
* stacktrace in production, set the `NODE_ENV` environment variable to
|
|
141
|
+
* `production`.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* throw new HttpError(HttpStatus.BadRequest, "Bad request")
|
|
146
|
+
* // OR
|
|
147
|
+
* throw new BadRequestError()
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
declare class HttpError extends Error {
|
|
151
|
+
readonly status: HttpStatus;
|
|
152
|
+
readonly additionalInfo?: Record<string, any> | undefined;
|
|
153
|
+
constructor(status: HttpStatus, message: string, additionalInfo?: Record<string, any> | undefined, options?: ErrorOptions);
|
|
154
|
+
}
|
|
155
|
+
/** Shorthand for `new HttpError(HttpStatus.BadRequest, "Bad Request", ...)` */
|
|
156
|
+
declare class BadRequestHttpError extends HttpError {
|
|
157
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
158
|
+
}
|
|
159
|
+
/** Shorthand for `new HttpError(HttpStatus.Unauthorized, "Unauthorized", ...)` */
|
|
160
|
+
declare class UnauthorizedHttpError extends HttpError {
|
|
161
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
162
|
+
}
|
|
163
|
+
/** Shorthand for `new HttpError(HttpStatus.PaymentRequired, "Payment Required", ...)` */
|
|
164
|
+
declare class PaymentRequiredHttpError extends HttpError {
|
|
165
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
166
|
+
}
|
|
167
|
+
/** Shorthand for `new HttpError(HttpStatus.Forbidden, "Forbidden", ...)` */
|
|
168
|
+
declare class ForbiddenHttpError extends HttpError {
|
|
169
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
170
|
+
}
|
|
171
|
+
/** Shorthand for `new HttpError(HttpStatus.NotFound, "Not Found", ...)` */
|
|
172
|
+
declare class NotFoundHttpError extends HttpError {
|
|
173
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
174
|
+
}
|
|
175
|
+
/** Shorthand for `new HttpError(HttpStatus.MethodNotAllowed, "Method Not Allowed", ...)` */
|
|
176
|
+
declare class MethodNotAllowedHttpError extends HttpError {
|
|
177
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
178
|
+
}
|
|
179
|
+
/** Shorthand for `new HttpError(HttpStatus.NotAcceptable, "Not Acceptable", ...)` */
|
|
180
|
+
declare class NotAcceptableHttpError extends HttpError {
|
|
181
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
182
|
+
}
|
|
183
|
+
/** Shorthand for `new HttpError(HttpStatus.ProxyAuthenticationRequired, "Proxy Authentication Required", ...)` */
|
|
184
|
+
declare class ProxyAuthenticationRequiredHttpError extends HttpError {
|
|
185
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
186
|
+
}
|
|
187
|
+
/** Shorthand for `new HttpError(HttpStatus.RequestTimeout, "Request Timeout", ...)` */
|
|
188
|
+
declare class RequestTimeoutHttpError extends HttpError {
|
|
189
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
190
|
+
}
|
|
191
|
+
/** Shorthand for `new HttpError(HttpStatus.Conflict, "Conflict", ...)` */
|
|
192
|
+
declare class ConflictHttpError extends HttpError {
|
|
193
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
194
|
+
}
|
|
195
|
+
/** Shorthand for `new HttpError(HttpStatus.Gone, "Gone", ...)` */
|
|
196
|
+
declare class GoneHttpError extends HttpError {
|
|
197
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
198
|
+
}
|
|
199
|
+
/** Shorthand for `new HttpError(HttpStatus.LengthRequired, "Length Required", ...)` */
|
|
200
|
+
declare class LengthRequiredHttpError extends HttpError {
|
|
201
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
202
|
+
}
|
|
203
|
+
/** Shorthand for `new HttpError(HttpStatus.PreconditionFailed, "Precondition Failed", ...)` */
|
|
204
|
+
declare class PreconditionFailedHttpError extends HttpError {
|
|
205
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
206
|
+
}
|
|
207
|
+
/** Shorthand for `new HttpError(HttpStatus.ContentTooLarge, "Content Too Large", ...)` */
|
|
208
|
+
declare class ContentTooLargeHttpError extends HttpError {
|
|
209
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
210
|
+
}
|
|
211
|
+
/** Shorthand for `new HttpError(HttpStatus.UriTooLong, "URI Too Long", ...)` */
|
|
212
|
+
declare class UriTooLongHttpError extends HttpError {
|
|
213
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
214
|
+
}
|
|
215
|
+
/** Shorthand for `new HttpError(HttpStatus.UnsupportedMediaType, "Unsupported Media Type", ...)` */
|
|
216
|
+
declare class UnsupportedMediaTypeHttpError extends HttpError {
|
|
217
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
218
|
+
}
|
|
219
|
+
/** Shorthand for `new HttpError(HttpStatus.RangeNotSatisfiable, "Range Not Satisfiable", ...)` */
|
|
220
|
+
declare class RangeNotSatisfiableHttpError extends HttpError {
|
|
221
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
222
|
+
}
|
|
223
|
+
/** Shorthand for `new HttpError(HttpStatus.ExpectationFailed, "Expectation Failed", ...)` */
|
|
224
|
+
declare class ExpectationFailedHttpError extends HttpError {
|
|
225
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
226
|
+
}
|
|
227
|
+
/** Shorthand for `new HttpError(HttpStatus.ImATeapot, "I'm a Teapot", ...)` */
|
|
228
|
+
declare class ImATeapotHttpError extends HttpError {
|
|
229
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
230
|
+
}
|
|
231
|
+
/** Shorthand for `new HttpError(HttpStatus.MisdirectedRequest, "Misdirected Request", ...)` */
|
|
232
|
+
declare class MisdirectedRequestHttpError extends HttpError {
|
|
233
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
234
|
+
}
|
|
235
|
+
/** Shorthand for `new HttpError(HttpStatus.UnprocessableEntity, "Unprocessable Entity", ...)` */
|
|
236
|
+
declare class UnprocessableEntityHttpError extends HttpError {
|
|
237
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
238
|
+
}
|
|
239
|
+
/** Shorthand for `new HttpError(HttpStatus.Locked, "Locked", ...)` */
|
|
240
|
+
declare class LockedHttpError extends HttpError {
|
|
241
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
242
|
+
}
|
|
243
|
+
/** Shorthand for `new HttpError(HttpStatus.FailedDependency, "Failed Dependency", ...)` */
|
|
244
|
+
declare class FailedDependencyHttpError extends HttpError {
|
|
245
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
246
|
+
}
|
|
247
|
+
/** Shorthand for `new HttpError(HttpStatus.TooEarly, "Too Early", ...)` */
|
|
248
|
+
declare class TooEarlyHttpError extends HttpError {
|
|
249
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
250
|
+
}
|
|
251
|
+
/** Shorthand for `new HttpError(HttpStatus.UpgradeRequired, "Upgrade Required", ...)` */
|
|
252
|
+
declare class UpgradeRequiredHttpError extends HttpError {
|
|
253
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
254
|
+
}
|
|
255
|
+
/** Shorthand for `new HttpError(HttpStatus.PreconditionRequired, "Precondition Required", ...)` */
|
|
256
|
+
declare class PreconditionRequiredHttpError extends HttpError {
|
|
257
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
258
|
+
}
|
|
259
|
+
/** Shorthand for `new HttpError(HttpStatus.TooManyRequests, "Too Many Requests", ...)` */
|
|
260
|
+
declare class TooManyRequestsHttpError extends HttpError {
|
|
261
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
262
|
+
}
|
|
263
|
+
/** Shorthand for `new HttpError(HttpStatus.RequestHeaderFieldsTooLarge, "Request Header Fields Too Large", ...)` */
|
|
264
|
+
declare class RequestHeaderFieldsTooLargeHttpError extends HttpError {
|
|
265
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
266
|
+
}
|
|
267
|
+
/** Shorthand for `new HttpError(HttpStatus.UnavailableForLegalReasons, "Unavailable For Legal Reasons", ...)` */
|
|
268
|
+
declare class UnavailableForLegalReasonsHttpError extends HttpError {
|
|
269
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
270
|
+
}
|
|
271
|
+
/** Shorthand for `new HttpError(HttpStatus.InternalServerError, "Internal Server Error", ...)` */
|
|
272
|
+
declare class InternalServerErrorHttpError extends HttpError {
|
|
273
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
274
|
+
}
|
|
275
|
+
/** Shorthand for `new HttpError(HttpStatus.NotImplemented, "Not Implemented", ...)` */
|
|
276
|
+
declare class NotImplementedHttpError extends HttpError {
|
|
277
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
278
|
+
}
|
|
279
|
+
/** Shorthand for `new HttpError(HttpStatus.BadGateway, "Bad Gateway", ...)` */
|
|
280
|
+
declare class BadGatewayHttpError extends HttpError {
|
|
281
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
282
|
+
}
|
|
283
|
+
/** Shorthand for `new HttpError(HttpStatus.ServiceUnavailable, "Service Unavailable", ...)` */
|
|
284
|
+
declare class ServiceUnavailableHttpError extends HttpError {
|
|
285
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
286
|
+
}
|
|
287
|
+
/** Shorthand for `new HttpError(HttpStatus.GatewayTimeout, "Gateway Timeout", ...)` */
|
|
288
|
+
declare class GatewayTimeoutHttpError extends HttpError {
|
|
289
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
290
|
+
}
|
|
291
|
+
/** Shorthand for `new HttpError(HttpStatus.HttpVersionNotSupported, "HTTP Version Not Supported", ...)` */
|
|
292
|
+
declare class HttpVersionNotSupportedHttpError extends HttpError {
|
|
293
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
294
|
+
}
|
|
295
|
+
/** Shorthand for `new HttpError(HttpStatus.VariantAlsoNegotiates, "Variant Also Negotiates", ...)` */
|
|
296
|
+
declare class VariantAlsoNegotiatesHttpError extends HttpError {
|
|
297
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
298
|
+
}
|
|
299
|
+
/** Shorthand for `new HttpError(HttpStatus.InsufficientStorage, "Insufficient Storage", ...)` */
|
|
300
|
+
declare class InsufficientStorageHttpError extends HttpError {
|
|
301
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
302
|
+
}
|
|
303
|
+
/** Shorthand for `new HttpError(HttpStatus.LoopDetected, "Loop Detected", ...)` */
|
|
304
|
+
declare class LoopDetectedHttpError extends HttpError {
|
|
305
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
306
|
+
}
|
|
307
|
+
/** Shorthand for `new HttpError(HttpStatus.NotExtended, "Not Extended", ...)` */
|
|
308
|
+
declare class NotExtendedHttpError extends HttpError {
|
|
309
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
310
|
+
}
|
|
311
|
+
/** Shorthand for `new HttpError(HttpStatus.NetworkAuthenticationRequired, "Network Authentication Required", ...)` */
|
|
312
|
+
declare class NetworkAuthenticationRequiredHttpError extends HttpError {
|
|
313
|
+
constructor(message?: string, additionalInfo?: Record<string, any>, options?: ErrorOptions);
|
|
314
|
+
}
|
|
315
|
+
//#endregion
|
|
316
|
+
export { type App, BadGatewayHttpError, BadRequestHttpError, ConflictHttpError, ContentTooLargeHttpError, CreateAppOptions, ErrorResponse, ExpectationFailedHttpError, FailedDependencyHttpError, ForbiddenHttpError, GatewayTimeoutHttpError, GoneHttpError, HttpError, HttpStatus, HttpVersionNotSupportedHttpError, ImATeapotHttpError, InsufficientStorageHttpError, InternalServerErrorHttpError, LengthRequiredHttpError, LockedHttpError, LoopDetectedHttpError, MethodNotAllowedHttpError, MisdirectedRequestHttpError, NetworkAuthenticationRequiredHttpError, NoResponse, NotAcceptableHttpError, NotExtendedHttpError, NotFoundHttpError, NotImplementedHttpError, PaymentRequiredHttpError, PreconditionFailedHttpError, PreconditionRequiredHttpError, ProxyAuthenticationRequiredHttpError, RangeNotSatisfiableHttpError, RequestHeaderFieldsTooLargeHttpError, RequestTimeoutHttpError, ServiceUnavailableHttpError, TooEarlyHttpError, TooManyRequestsHttpError, UnauthorizedHttpError, UnavailableForLegalReasonsHttpError, UnprocessableEntityHttpError, UnsupportedMediaTypeHttpError, UpgradeRequiredHttpError, UriTooLongHttpError, VariantAlsoNegotiatesHttpError, type ZetaSchema, createApp, getHttpStatusName };
|