tritio 0.1.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,127 @@
1
+ import { Type } from 'typebox';
2
+ export declare const t: {
3
+ Email: (options?: any) => Type.TString;
4
+ Numeric: (options?: any) => Type.TNumber;
5
+ Instantiate: typeof Type.Instantiate;
6
+ Extends: typeof Type.Extends;
7
+ ExtendsResult: typeof Type.ExtendsResult;
8
+ Script: typeof Type.Script;
9
+ Awaited: typeof Type.Awaited;
10
+ Capitalize: typeof Type.Capitalize;
11
+ Conditional: typeof Type.Conditional;
12
+ ConstructorParameters: typeof Type.ConstructorParameters;
13
+ Evaluate: typeof Type.Evaluate;
14
+ Exclude: typeof Type.Exclude;
15
+ Extract: typeof Type.Extract;
16
+ Index: typeof Type.Index;
17
+ InstanceType: typeof Type.InstanceType;
18
+ Interface: typeof Type.Interface;
19
+ KeyOf: typeof Type.KeyOf;
20
+ Lowercase: typeof Type.Lowercase;
21
+ Mapped: typeof Type.Mapped;
22
+ Module: typeof Type.Module;
23
+ NonNullable: typeof Type.NonNullable;
24
+ Omit: typeof Type.Omit;
25
+ Options: typeof Type.Options;
26
+ Parameters: typeof Type.Parameters;
27
+ Partial: typeof Type.Partial;
28
+ Pick: typeof Type.Pick;
29
+ ReadonlyType: typeof Type.ReadonlyType;
30
+ Required: typeof Type.Required;
31
+ ReturnType: typeof Type.ReturnType;
32
+ Uncapitalize: typeof Type.Uncapitalize;
33
+ Uppercase: typeof Type.Uppercase;
34
+ Codec: typeof Type.Codec;
35
+ Decode: typeof Type.Decode;
36
+ DecodeBuilder: typeof Type.DecodeBuilder;
37
+ Encode: typeof Type.Encode;
38
+ EncodeBuilder: typeof Type.EncodeBuilder;
39
+ IsCodec: typeof Type.IsCodec;
40
+ Immutable: typeof Type.Immutable;
41
+ IsImmutable: typeof Type.IsImmutable;
42
+ IsOptional: typeof Type.IsOptional;
43
+ Optional: typeof Type.Optional;
44
+ IsReadonly: typeof Type.IsReadonly;
45
+ Readonly: typeof Type.Readonly;
46
+ IsRefine: typeof Type.IsRefine;
47
+ Refine: typeof Type.Refine;
48
+ Any: typeof Type.Any;
49
+ IsAny: typeof Type.IsAny;
50
+ Array: typeof Type.Array;
51
+ IsArray: typeof Type.IsArray;
52
+ AsyncIterator: typeof Type.AsyncIterator;
53
+ IsAsyncIterator: typeof Type.IsAsyncIterator;
54
+ Base: typeof Type.Base;
55
+ IsBase: typeof Type.IsBase;
56
+ BigInt: typeof Type.BigInt;
57
+ IsBigInt: typeof Type.IsBigInt;
58
+ Boolean: typeof Type.Boolean;
59
+ IsBoolean: typeof Type.IsBoolean;
60
+ Call: typeof Type.Call;
61
+ IsCall: typeof Type.IsCall;
62
+ Constructor: typeof Type.Constructor;
63
+ IsConstructor: typeof Type.IsConstructor;
64
+ Cyclic: typeof Type.Cyclic;
65
+ IsCyclic: typeof Type.IsCyclic;
66
+ Enum: typeof Type.Enum;
67
+ IsEnum: typeof Type.IsEnum;
68
+ Function: typeof Type.Function;
69
+ IsFunction: typeof Type.IsFunction;
70
+ Generic: typeof Type.Generic;
71
+ IsGeneric: typeof Type.IsGeneric;
72
+ Identifier: typeof Type.Identifier;
73
+ IsIdentifier: typeof Type.IsIdentifier;
74
+ Infer: typeof Type.Infer;
75
+ IsInfer: typeof Type.IsInfer;
76
+ Integer: typeof Type.Integer;
77
+ IsInteger: typeof Type.IsInteger;
78
+ Intersect: typeof Type.Intersect;
79
+ IsIntersect: typeof Type.IsIntersect;
80
+ IsIterator: typeof Type.IsIterator;
81
+ Iterator: typeof Type.Iterator;
82
+ IsLiteral: typeof Type.IsLiteral;
83
+ Literal: typeof Type.Literal;
84
+ IsNever: typeof Type.IsNever;
85
+ Never: typeof Type.Never;
86
+ IsNull: typeof Type.IsNull;
87
+ Null: typeof Type.Null;
88
+ IsNumber: typeof Type.IsNumber;
89
+ Number: typeof Type.Number;
90
+ IsObject: typeof Type.IsObject;
91
+ Object: typeof Type.Object;
92
+ IsParameter: typeof Type.IsParameter;
93
+ Parameter: typeof Type.Parameter;
94
+ IsPromise: typeof Type.IsPromise;
95
+ Promise: typeof Type.Promise;
96
+ IsRecord: typeof Type.IsRecord;
97
+ Record: typeof Type.Record;
98
+ RecordKey: typeof Type.RecordKey;
99
+ RecordKeyAsPattern: typeof Type.RecordKeyAsPattern;
100
+ RecordValue: typeof Type.RecordValue;
101
+ IsRef: typeof Type.IsRef;
102
+ Ref: typeof Type.Ref;
103
+ IsRest: typeof Type.IsRest;
104
+ Rest: typeof Type.Rest;
105
+ IsKind: typeof Type.IsKind;
106
+ IsSchema: typeof Type.IsSchema;
107
+ IsString: typeof Type.IsString;
108
+ String: typeof Type.String;
109
+ IsSymbol: typeof Type.IsSymbol;
110
+ Symbol: typeof Type.Symbol;
111
+ IsTemplateLiteral: typeof Type.IsTemplateLiteral;
112
+ TemplateLiteral: typeof Type.TemplateLiteral;
113
+ IsThis: typeof Type.IsThis;
114
+ This: typeof Type.This;
115
+ IsTuple: typeof Type.IsTuple;
116
+ Tuple: typeof Type.Tuple;
117
+ IsUndefined: typeof Type.IsUndefined;
118
+ Undefined: typeof Type.Undefined;
119
+ IsUnion: typeof Type.IsUnion;
120
+ Union: typeof Type.Union;
121
+ IsUnknown: typeof Type.IsUnknown;
122
+ Unknown: typeof Type.Unknown;
123
+ IsUnsafe: typeof Type.IsUnsafe;
124
+ Unsafe: typeof Type.Unsafe;
125
+ IsVoid: typeof Type.IsVoid;
126
+ Void: typeof Type.Void;
127
+ };
@@ -0,0 +1,23 @@
1
+ import { type RouteSchema, type Context, type MiddlewareHandler, type TritioOptions } from './types';
2
+ export declare class Tritio {
3
+ private h3;
4
+ private middlewares;
5
+ private routes;
6
+ private prefix;
7
+ constructor(options?: TritioOptions);
8
+ use(handler: MiddlewareHandler): this;
9
+ mount(prefix: string, app: Tritio): this;
10
+ group(prefix: string, callback: (app: Tritio) => void): this;
11
+ private joinPaths;
12
+ private register;
13
+ get<S extends RouteSchema>(path: string, schema: S, handler: (c: Context<S>) => any): this;
14
+ post<S extends RouteSchema>(path: string, schema: S, handler: (c: Context<S>) => any): this;
15
+ put<S extends RouteSchema>(path: string, schema: S, handler: (c: Context<S>) => any): this;
16
+ delete<S extends RouteSchema>(path: string, schema: S, handler: (c: Context<S>) => any): this;
17
+ patch<S extends RouteSchema>(path: string, schema: S, handler: (c: Context<S>) => any): this;
18
+ head<S extends RouteSchema>(path: string, schema: S, handler: (c: Context<S>) => any): this;
19
+ options<S extends RouteSchema>(path: string, schema: S, handler: (c: Context<S>) => any): this;
20
+ docs(path?: string): void;
21
+ get fetch(): (request: Request | string, init?: RequestInit) => Promise<Response>;
22
+ listen(port: number, callback?: () => void): void;
23
+ }
@@ -0,0 +1,31 @@
1
+ import { type Static, type TSchema } from 'typebox';
2
+ import { H3Event } from 'h3';
3
+ export interface TritioOptions {
4
+ prefix?: string;
5
+ cors?: CorsOptions | boolean;
6
+ }
7
+ export interface RouteSchema {
8
+ body?: TSchema;
9
+ query?: TSchema;
10
+ params?: TSchema;
11
+ response?: TSchema;
12
+ }
13
+ export interface Context<S extends RouteSchema> {
14
+ event: H3Event;
15
+ body: S['body'] extends TSchema ? Static<S['body']> : unknown;
16
+ query: S['query'] extends TSchema ? Static<S['query']> : Record<string, string>;
17
+ params: S['params'] extends TSchema ? Static<S['params']> : Record<string, string>;
18
+ }
19
+ export interface CorsOptions {
20
+ origin?: string | string[] | ((origin: string) => boolean);
21
+ methods?: string[];
22
+ allowHeaders?: string[];
23
+ exposeHeaders?: string[];
24
+ credentials?: boolean;
25
+ maxAge?: number;
26
+ preflight?: {
27
+ statusCode?: number;
28
+ };
29
+ }
30
+ export type Next = () => Promise<void>;
31
+ export type MiddlewareHandler = (ctx: Context<any>, next: Next) => Promise<void> | void;
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "tritio",
3
+ "version": "0.1.0",
4
+ "description": "The fast, opinionated h3 framework",
5
+ "type": "module",
6
+ "main": "./dist/index.mjs",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.mjs",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "scripts": {
22
+ "build": "bun build ./src/index.ts --outdir ./dist --target bun && tsc --emitDeclarationOnly --outDir dist"
23
+ },
24
+ "dependencies": {
25
+ "h3": "^2.0.1-rc.8",
26
+ "typebox": "^1.0.78"
27
+ }
28
+ }