tritio 0.1.2 → 0.3.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/core/context.d.ts +9 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/lifecycle.d.ts +20 -0
- package/dist/core/pipeline.d.ts +7 -0
- package/dist/core/registry.d.ts +12 -0
- package/dist/{error/http-error.d.ts → http/errors.d.ts} +8 -3
- package/dist/http/index.d.ts +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +9916 -8116
- package/dist/logger.d.ts +9 -0
- package/dist/tritio.d.ts +62 -18
- package/dist/types.d.ts +39 -18
- package/dist/validation/compiler.d.ts +9 -0
- package/dist/validation/index.d.ts +2 -0
- package/dist/{schema.d.ts → validation/schema.d.ts} +5 -2
- package/package.json +6 -1
- package/dist/docs/index.d.ts +0 -2
- package/dist/docs/openapi.d.ts +0 -9
- package/dist/docs/scalar.d.ts +0 -1
- package/dist/error/handler.d.ts +0 -2
- package/dist/http/cors.d.ts +0 -3
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { H3Event } from 'h3';
|
|
2
|
+
import { Context, RouteSchema } from '../types';
|
|
3
|
+
export type InternalContext<S extends RouteSchema, Env> = Context<S, Env> & {
|
|
4
|
+
_query?: Record<string, unknown>;
|
|
5
|
+
_params?: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
export declare class ContextFactory {
|
|
8
|
+
static create<S extends RouteSchema, Env>(event: H3Event, rawBody: unknown): Context<S, Env>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { H3Event, HTTPError as NativeH3Error } from 'h3';
|
|
2
|
+
import { GlobalHook, ErrorHook, TransformHook, ContextHook } from '../types';
|
|
3
|
+
import { HTTPError } from '../http';
|
|
4
|
+
export declare class LifecycleManager<Env> {
|
|
5
|
+
onRequestHooks: GlobalHook[];
|
|
6
|
+
onResponseHooks: Array<(response: any, event: H3Event) => void | Promise<void>>;
|
|
7
|
+
onErrorHooks: ErrorHook[];
|
|
8
|
+
onTransformHooks: TransformHook<Env>[];
|
|
9
|
+
onBeforeHandleHooks: ContextHook<Env>[];
|
|
10
|
+
onAfterHandleHooks: ContextHook<Env>[];
|
|
11
|
+
addRequest(fn: GlobalHook): void;
|
|
12
|
+
addResponse(fn: (res: any, event: H3Event) => void): void;
|
|
13
|
+
addError(fn: ErrorHook): void;
|
|
14
|
+
addTransform(fn: TransformHook<Env>): void;
|
|
15
|
+
addBeforeHandle(fn: ContextHook<Env>): void;
|
|
16
|
+
addAfterHandle(fn: ContextHook<Env>): void;
|
|
17
|
+
runOnRequest(event: H3Event): Promise<void>;
|
|
18
|
+
runOnResponse(response: any, event: H3Event): Promise<void>;
|
|
19
|
+
runOnError(error: HTTPError | NativeH3Error, event: H3Event): Promise<Response>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EventHandlerResponse, H3Event } from 'h3';
|
|
2
|
+
import { HTTPMethod } from '../http';
|
|
3
|
+
import { Context, RouteSchema } from '../types';
|
|
4
|
+
import { LifecycleManager } from './lifecycle';
|
|
5
|
+
export declare class ExecutionPipeline {
|
|
6
|
+
static build<S extends RouteSchema, Env>(schema: S, lifecycle: LifecycleManager<Env>, handler: (ctx: Context<S, Env>) => unknown, method: HTTPMethod): (event: H3Event) => Promise<EventHandlerResponse>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HTTPMethod } from '../http/methods';
|
|
2
|
+
import { RouteSchema } from '../types';
|
|
3
|
+
export interface RegisteredRoute {
|
|
4
|
+
method: HTTPMethod;
|
|
5
|
+
path: string;
|
|
6
|
+
schema: RouteSchema;
|
|
7
|
+
}
|
|
8
|
+
export declare class RouteRegistry {
|
|
9
|
+
private routes;
|
|
10
|
+
add(method: HTTPMethod, path: string, schema: RouteSchema): void;
|
|
11
|
+
getAll(): RegisteredRoute[];
|
|
12
|
+
}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
import { HTTPError as H3Error } from 'h3';
|
|
1
2
|
export interface HTTPErrorOptions {
|
|
2
3
|
res?: Response;
|
|
3
4
|
message?: string;
|
|
4
5
|
cause?: unknown;
|
|
5
6
|
}
|
|
6
|
-
export declare class HTTPError extends
|
|
7
|
+
export declare class HTTPError extends H3Error {
|
|
7
8
|
readonly status: number;
|
|
9
|
+
statusText: string;
|
|
8
10
|
readonly res?: Response;
|
|
9
|
-
|
|
11
|
+
cause: unknown;
|
|
10
12
|
constructor(status: number, options?: HTTPErrorOptions);
|
|
13
|
+
get statusCode(): number;
|
|
14
|
+
get statusMessage(): string;
|
|
11
15
|
getResponse(): Response;
|
|
12
|
-
private
|
|
16
|
+
private static getStatusText;
|
|
13
17
|
}
|
|
14
18
|
export declare class BadRequestException extends HTTPError {
|
|
15
19
|
constructor(options?: HTTPErrorOptions);
|
|
@@ -65,3 +69,4 @@ export declare class ServiceUnavailableException extends HTTPError {
|
|
|
65
69
|
export declare class GatewayTimeoutException extends HTTPError {
|
|
66
70
|
constructor(options?: HTTPErrorOptions);
|
|
67
71
|
}
|
|
72
|
+
export declare const errorHandler: (error: H3Error | HTTPError) => Response;
|
package/dist/http/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './methods';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './errors';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { Tritio } from './tritio';
|
|
2
2
|
export * from './types';
|
|
3
3
|
export * from './tritio';
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './docs';
|
|
4
|
+
export * from './validation';
|
|
5
|
+
export * from './core';
|
|
7
6
|
export * from './http';
|
|
7
|
+
export type InferApp<T> = T extends Tritio<any, infer S> ? S : never;
|