tritio 0.1.2 → 0.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.
@@ -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,2 @@
1
+ export * from './pipeline';
2
+ export * from './context';
@@ -0,0 +1,6 @@
1
+ import { EventHandlerResponse, H3Event } from 'h3';
2
+ import { HTTPMethod } from '../http';
3
+ import { Context, MiddlewareHandler, RouteSchema } from '../types';
4
+ export declare class ExecutionPipeline {
5
+ static build<S extends RouteSchema, Env>(schema: S, middlewares: MiddlewareHandler<Env>[], handler: (ctx: Context<S, Env>) => unknown, method: HTTPMethod): (event: H3Event) => Promise<EventHandlerResponse>;
6
+ }
@@ -1,9 +1,20 @@
1
- export declare const generateOpenApiSpec: (routes: any[]) => {
1
+ import { HTTPMethod } from '../http/methods';
2
+ import { RouteSchema } from '../types';
3
+ interface Route {
4
+ method: HTTPMethod;
5
+ path: string;
6
+ schema: RouteSchema;
7
+ }
8
+ interface OpenApiPaths {
9
+ [key: string]: Record<string, unknown>;
10
+ }
11
+ export declare const generateOpenApiSpec: (routes: Route[]) => {
2
12
  openapi: string;
3
13
  info: {
4
14
  title: string;
5
15
  version: string;
6
16
  description: string;
7
17
  };
8
- paths: any;
18
+ paths: OpenApiPaths;
9
19
  };
20
+ export {};
@@ -1,3 +1,4 @@
1
+ import { HTTPError as H3Error } from 'h3';
1
2
  export interface HTTPErrorOptions {
2
3
  res?: Response;
3
4
  message?: string;
@@ -65,3 +66,4 @@ export declare class ServiceUnavailableException extends HTTPError {
65
66
  export declare class GatewayTimeoutException extends HTTPError {
66
67
  constructor(options?: HTTPErrorOptions);
67
68
  }
69
+ export declare const errorHandler: (error: H3Error | HTTPError) => Response;
@@ -1,2 +1,3 @@
1
1
  export * from './methods';
2
2
  export * from './cors';
3
+ export * from './errors';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- export * from './schema';
1
+ import { Tritio } from './tritio';
2
2
  export * from './types';
3
3
  export * from './tritio';
4
- export * from './error/http-error';
5
- export * from './error/handler';
4
+ export * from './validation';
5
+ export * from './core';
6
6
  export * from './docs';
7
7
  export * from './http';
8
+ export type InferApp<T> = T extends Tritio<any, infer S> ? S : never;