elysia 0.6.2 → 0.6.4
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/bun/index.d.ts +65 -91
- package/dist/bun/index.js +21 -21
- package/dist/bun/index.js.map +7 -7
- package/dist/cjs/compose.d.ts +3 -3
- package/dist/cjs/compose.js +2 -2
- package/dist/cjs/dynamic-handle.d.ts +2 -2
- package/dist/cjs/dynamic-handle.js +1 -1
- package/dist/cjs/error.d.ts +4 -4
- package/dist/cjs/error.js +5 -10
- package/dist/cjs/index.d.ts +65 -91
- package/dist/cjs/index.js +7 -4
- package/dist/cjs/types.d.ts +4 -5
- package/dist/cjs/ws/index.d.ts +1 -2
- package/dist/compose.d.ts +3 -3
- package/dist/compose.js +2 -2
- package/dist/dynamic-handle.d.ts +2 -2
- package/dist/dynamic-handle.js +1 -1
- package/dist/error.d.ts +4 -4
- package/dist/error.js +2 -2
- package/dist/index.d.ts +65 -91
- package/dist/index.js +4 -4
- package/dist/types.d.ts +4 -5
- package/dist/ws/index.d.ts +1 -2
- package/package.json +1 -1
package/dist/bun/index.d.ts
CHANGED
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
import type { Serve, Server } from 'bun';
|
|
3
3
|
import type { Context } from './context';
|
|
4
4
|
import type { ElysiaWSOptions, WSTypedSchema } from './ws';
|
|
5
|
-
import type { Handler, VoidRequestHandler, TypedRoute, ElysiaInstance, ElysiaConfig, HTTPMethod, InternalRoute, BodyParser, ErrorHandler, TypedSchema, LocalHook, LocalHandler, LifeCycle, LifeCycleEvent, LifeCycleStore, VoidLifeCycle, AfterRequestHandler, IsAny, OverwritableTypeRoute, MergeSchema, ListenCallback, NoReturnHandler, MaybePromise, Prettify, TypedWSRouteToEden, UnwrapSchema, ExtractPath, TypedSchemaToRoute, DeepWritable, Reconciliation, BeforeRequestHandler } from './types';
|
|
5
|
+
import type { Handler, VoidRequestHandler, TypedRoute, ElysiaInstance, ElysiaConfig, HTTPMethod, InternalRoute, BodyParser, ErrorHandler, TypedSchema, LocalHook, LocalHandler, LifeCycle, LifeCycleEvent, LifeCycleStore, VoidLifeCycle, AfterRequestHandler, IsAny, OverwritableTypeRoute, MergeSchema, ListenCallback, NoReturnHandler, MaybePromise, Prettify, TypedWSRouteToEden, UnwrapSchema, ExtractPath, TypedSchemaToRoute, DeepWritable, Reconciliation, BeforeRequestHandler, ElysiaDefaultMeta } from './types';
|
|
6
6
|
import type { Static, TSchema } from '@sinclair/typebox';
|
|
7
|
-
export default class Elysia<
|
|
7
|
+
export default class Elysia<BasePath extends string = '', Instance extends ElysiaInstance<{
|
|
8
|
+
store?: Record<string, unknown>;
|
|
9
|
+
request?: Record<string, unknown>;
|
|
10
|
+
error?: Record<string, Error>;
|
|
11
|
+
schema?: TypedSchema<any>;
|
|
12
|
+
meta?: ElysiaDefaultMeta;
|
|
13
|
+
}> = {
|
|
8
14
|
path: '';
|
|
9
15
|
store: {};
|
|
10
16
|
request: {};
|
|
@@ -16,7 +22,7 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
16
22
|
exposed: {};
|
|
17
23
|
};
|
|
18
24
|
}> {
|
|
19
|
-
config: ElysiaConfig
|
|
25
|
+
config: ElysiaConfig<BasePath>;
|
|
20
26
|
private dependencies;
|
|
21
27
|
store: Instance['store'];
|
|
22
28
|
meta: Instance['meta'];
|
|
@@ -31,8 +37,8 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
31
37
|
private wsRouter;
|
|
32
38
|
private dynamicRouter;
|
|
33
39
|
private lazyLoadModules;
|
|
34
|
-
path:
|
|
35
|
-
constructor(config?: Partial<ElysiaConfig
|
|
40
|
+
path: BasePath;
|
|
41
|
+
constructor(config?: Partial<ElysiaConfig<BasePath>>);
|
|
36
42
|
private add;
|
|
37
43
|
onStart(handler: VoidLifeCycle<Instance>): this;
|
|
38
44
|
onRequest<Route extends OverwritableTypeRoute = TypedRoute>(handler: BeforeRequestHandler<Route, Instance>): this;
|
|
@@ -43,8 +49,7 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
43
49
|
onResponse<Route extends OverwritableTypeRoute = TypedRoute>(handler: VoidRequestHandler<Route, Instance>): this;
|
|
44
50
|
addError<const Errors extends Record<string, {
|
|
45
51
|
prototype: Error;
|
|
46
|
-
}>>(errors: Errors): Elysia<{
|
|
47
|
-
path: Instance['path'];
|
|
52
|
+
}>>(errors: Errors): Elysia<BasePath, {
|
|
48
53
|
store: Instance['store'];
|
|
49
54
|
error: Instance['error'] & {
|
|
50
55
|
[K in NonNullable<keyof Errors>]: Errors[K] extends {
|
|
@@ -57,8 +62,7 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
57
62
|
}>;
|
|
58
63
|
addError<Name extends string, const CustomError extends {
|
|
59
64
|
prototype: Error;
|
|
60
|
-
}>(name: Name, errors: CustomError): Elysia<{
|
|
61
|
-
path: Instance['path'];
|
|
65
|
+
}>(name: Name, errors: CustomError): Elysia<BasePath, {
|
|
62
66
|
store: Instance['store'];
|
|
63
67
|
error: Instance['error'] & {
|
|
64
68
|
[name in Name]: CustomError extends {
|
|
@@ -69,8 +73,7 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
69
73
|
schema: Instance['schema'];
|
|
70
74
|
meta: Instance['meta'];
|
|
71
75
|
}>;
|
|
72
|
-
onError(handler?: ErrorHandler<Instance['error']>): Elysia<{
|
|
73
|
-
path: Instance['path'];
|
|
76
|
+
onError(handler?: ErrorHandler<Instance['error']>): Elysia<BasePath, {
|
|
74
77
|
store: Instance['store'];
|
|
75
78
|
error: Instance['error'];
|
|
76
79
|
request: Instance['request'];
|
|
@@ -79,8 +82,7 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
79
82
|
}>;
|
|
80
83
|
onStop(handler: VoidLifeCycle<Instance>): this;
|
|
81
84
|
on<Event extends LifeCycleEvent = LifeCycleEvent>(type: Event, handler: LifeCycle<Instance>[Event]): this;
|
|
82
|
-
group<NewElysia extends Elysia<any> = Elysia<any>, Prefix extends string = string>(prefix: Prefix, run: (group: Elysia
|
|
83
|
-
path: `${Instance['path']}${Prefix}`;
|
|
85
|
+
group<NewElysia extends Elysia<any, any> = Elysia<any, any>, Prefix extends string = string>(prefix: Prefix, run: (group: Elysia<`${BasePath}${Prefix}`, {
|
|
84
86
|
error: Instance['error'];
|
|
85
87
|
request: Instance['request'];
|
|
86
88
|
store: Instance['store'] & ElysiaInstance['store'];
|
|
@@ -90,8 +92,7 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
90
92
|
defs: Instance['meta']['defs'];
|
|
91
93
|
exposed: {};
|
|
92
94
|
};
|
|
93
|
-
}>) => NewElysia): NewElysia extends Elysia
|
|
94
|
-
path: Instance['path'];
|
|
95
|
+
}>) => NewElysia): NewElysia extends Elysia<`${BasePath}${Prefix}`, infer NewInstance> ? Elysia<BasePath, {
|
|
95
96
|
error: Instance['error'];
|
|
96
97
|
request: Instance['request'];
|
|
97
98
|
schema: Instance['schema'];
|
|
@@ -100,8 +101,7 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
100
101
|
[key in keyof NewInstance['meta']['schema'] as key extends `${infer Rest}` ? `${Prefix}${Rest}` : key]: NewInstance['meta']['schema'][key];
|
|
101
102
|
}>);
|
|
102
103
|
}> : this;
|
|
103
|
-
group<Schema extends TypedSchema<Exclude<keyof Instance['meta']['defs'], number | symbol>>, NewElysia extends Elysia<any> = Elysia<any>, Prefix extends string = string>(prefix: Prefix, schema: LocalHook<Schema, Instance, `${
|
|
104
|
-
path: `${Instance['path']}${Prefix}`;
|
|
104
|
+
group<Schema extends TypedSchema<Exclude<keyof Instance['meta']['defs'], number | symbol>>, NewElysia extends Elysia<any, any> = Elysia<any, any>, Prefix extends string = string>(prefix: Prefix, schema: LocalHook<Schema, Instance, `${BasePath}${Prefix}`>, run: (group: Elysia<`${BasePath}${Prefix}`, {
|
|
105
105
|
error: Instance['error'];
|
|
106
106
|
request: Instance['request'];
|
|
107
107
|
store: Instance['store'] & ElysiaInstance['store'];
|
|
@@ -117,16 +117,16 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
117
117
|
defs: Instance['meta']['defs'];
|
|
118
118
|
exposed: {};
|
|
119
119
|
};
|
|
120
|
-
}>) => NewElysia): NewElysia extends Elysia
|
|
121
|
-
path: Instance['path'];
|
|
120
|
+
}>) => NewElysia): NewElysia extends Elysia<`${BasePath}${Prefix}`, infer NewInstance> ? Elysia<BasePath, {
|
|
122
121
|
error: Instance['error'];
|
|
123
122
|
request: Instance['request'];
|
|
124
123
|
schema: Instance['schema'];
|
|
125
124
|
store: Instance['store'];
|
|
126
|
-
meta: Instance['meta'] & NewInstance['meta']
|
|
125
|
+
meta: Instance['meta'] & (Omit<NewInstance['meta'], 'schema'> & Record<'schema', {
|
|
126
|
+
[key in keyof NewInstance['meta']['schema'] as key extends `${infer Rest}` ? `${Prefix}${Rest}` : key]: NewInstance['meta']['schema'][key];
|
|
127
|
+
}>);
|
|
127
128
|
}> : this;
|
|
128
|
-
guard<Schema extends TypedSchema<Exclude<keyof Instance['meta']['defs'], number | symbol>>>(hook: LocalHook<Schema, Instance>): Elysia<{
|
|
129
|
-
path: Instance['path'];
|
|
129
|
+
guard<Schema extends TypedSchema<Exclude<keyof Instance['meta']['defs'], number | symbol>>>(hook: LocalHook<Schema, Instance>): Elysia<any, {
|
|
130
130
|
error: Instance['error'];
|
|
131
131
|
request: Instance['request'];
|
|
132
132
|
store: Instance['store'];
|
|
@@ -135,8 +135,7 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
135
135
|
[key in keyof Schema]: Schema[key];
|
|
136
136
|
}>;
|
|
137
137
|
}>;
|
|
138
|
-
guard<Schema extends TypedSchema<Exclude<keyof Instance['meta']['defs'], number | symbol>>, NewElysia extends Elysia<any> = Elysia<any>>(hook: LocalHook<Schema, Instance>, run: (group: Elysia<{
|
|
139
|
-
path: Instance['path'];
|
|
138
|
+
guard<Schema extends TypedSchema<Exclude<keyof Instance['meta']['defs'], number | symbol>>, NewElysia extends Elysia<any, any> = Elysia<any, any>>(hook: LocalHook<Schema, Instance>, run: (group: Elysia<BasePath, {
|
|
140
139
|
error: Instance['error'];
|
|
141
140
|
request: Instance['request'];
|
|
142
141
|
store: Instance['store'];
|
|
@@ -148,8 +147,7 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
148
147
|
response: undefined extends Schema['response'] ? Instance['schema']['response'] : Schema['response'];
|
|
149
148
|
};
|
|
150
149
|
meta: Instance['meta'];
|
|
151
|
-
}>) => NewElysia): NewElysia extends Elysia<infer NewInstance> ? Elysia<{
|
|
152
|
-
path: Instance['path'];
|
|
150
|
+
}>) => NewElysia): NewElysia extends Elysia<any, infer NewInstance> ? Elysia<BasePath, {
|
|
153
151
|
error: Instance['error'];
|
|
154
152
|
request: Instance['request'];
|
|
155
153
|
store: Instance['store'];
|
|
@@ -158,8 +156,7 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
158
156
|
[key in keyof NewInstance['meta']['schema']]: NewInstance['meta']['schema'][key];
|
|
159
157
|
}>;
|
|
160
158
|
}> : this;
|
|
161
|
-
use<NewInstance extends ElysiaInstance, Params extends Elysia = Elysia<any>>(plugin: MaybePromise<(app: Params extends Elysia<infer ParamsInstance> ? IsAny<ParamsInstance> extends true ? this : any : Params) => MaybePromise<Elysia<NewInstance>>>): Elysia<{
|
|
162
|
-
path: Instance['path'];
|
|
159
|
+
use<NewInstance extends ElysiaInstance, Params extends Elysia = Elysia<any>>(plugin: MaybePromise<(app: Params extends Elysia<infer ParamsInstance> ? IsAny<ParamsInstance> extends true ? this : any : Params) => MaybePromise<Elysia<any, NewInstance>>>): Elysia<BasePath, {
|
|
163
160
|
error: Instance['error'] & NewInstance['error'];
|
|
164
161
|
request: Reconciliation<Instance['request'], NewInstance['request']>;
|
|
165
162
|
store: Reconciliation<Instance['store'], NewInstance['store']>;
|
|
@@ -170,8 +167,7 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
170
167
|
exposed: Instance['meta']['exposed'] & NewInstance['meta']['exposed'];
|
|
171
168
|
};
|
|
172
169
|
}>;
|
|
173
|
-
use<NewInstance extends ElysiaInstance>(instance: Elysia<NewInstance>): Elysia<{
|
|
174
|
-
path: NewInstance['path'];
|
|
170
|
+
use<NewInstance extends ElysiaInstance>(instance: Elysia<any, NewInstance>): Elysia<BasePath, {
|
|
175
171
|
error: Instance['error'] & NewInstance['error'];
|
|
176
172
|
request: Reconciliation<Instance['request'], NewInstance['request']>;
|
|
177
173
|
store: Reconciliation<Instance['store'], NewInstance['store']>;
|
|
@@ -183,9 +179,8 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
183
179
|
};
|
|
184
180
|
}>;
|
|
185
181
|
use<LazyLoadElysia extends ElysiaInstance>(plugin: Promise<{
|
|
186
|
-
default: (elysia: Elysia<any>) => MaybePromise<Elysia<LazyLoadElysia>>;
|
|
187
|
-
}>): Elysia<{
|
|
188
|
-
path: Instance['path'];
|
|
182
|
+
default: (elysia: Elysia<any, any>) => MaybePromise<Elysia<any, LazyLoadElysia>>;
|
|
183
|
+
}>): Elysia<BasePath, {
|
|
189
184
|
error: Instance['error'] & LazyLoadElysia['error'];
|
|
190
185
|
request: Reconciliation<Instance['request'], LazyLoadElysia['request']>;
|
|
191
186
|
store: Reconciliation<Instance['store'], LazyLoadElysia['store']>;
|
|
@@ -197,9 +192,8 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
197
192
|
};
|
|
198
193
|
}>;
|
|
199
194
|
use<LazyLoadElysia extends ElysiaInstance>(plugin: Promise<{
|
|
200
|
-
default: (elysia: Elysia<any>) => Elysia<LazyLoadElysia>;
|
|
201
|
-
}>): Elysia<{
|
|
202
|
-
path: Instance['path'];
|
|
195
|
+
default: (elysia: Elysia<any, any>) => Elysia<any, LazyLoadElysia>;
|
|
196
|
+
}>): Elysia<BasePath, {
|
|
203
197
|
error: Instance['error'] & LazyLoadElysia['error'];
|
|
204
198
|
request: Reconciliation<Instance['request'], LazyLoadElysia['request']>;
|
|
205
199
|
store: Reconciliation<Instance['store'], LazyLoadElysia['store']>;
|
|
@@ -212,8 +206,7 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
212
206
|
}>;
|
|
213
207
|
mount(handle: (request: Request) => MaybePromise<Response>): this;
|
|
214
208
|
mount(path: string, handle: (request: Request) => MaybePromise<Response>): this;
|
|
215
|
-
get<Path extends string, Handler extends LocalHandler<Schema, Instance, `${
|
|
216
|
-
path: Instance['path'];
|
|
209
|
+
get<Path extends string, Handler extends LocalHandler<Schema, Instance, `${BasePath}${Path}`>, Schema extends TypedSchema<Extract<keyof Instance['meta']['defs'], string>>>(path: Path, handler: Handler, hook?: LocalHook<Schema, Instance, `${BasePath}${Path}`>): Elysia<BasePath, {
|
|
217
210
|
request: Instance['request'];
|
|
218
211
|
store: Instance['store'];
|
|
219
212
|
schema: Instance['schema'];
|
|
@@ -222,7 +215,7 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
222
215
|
defs: Instance['meta']['defs'];
|
|
223
216
|
exposed: Instance['meta']['exposed'];
|
|
224
217
|
schema: Prettify<Instance['meta']['schema'] & (MergeSchema<Schema, Instance['schema']> extends infer Typed extends TypedSchema ? {
|
|
225
|
-
[path in
|
|
218
|
+
[path in Path]: {
|
|
226
219
|
get: {
|
|
227
220
|
body: UnwrapSchema<Typed['body'], Instance['meta']['defs']>;
|
|
228
221
|
headers: UnwrapSchema<Typed['headers'], Instance['meta']['defs']> extends infer Result ? Result extends Record<string, any> ? Result : undefined : undefined;
|
|
@@ -240,14 +233,13 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
240
233
|
} : {})>;
|
|
241
234
|
};
|
|
242
235
|
}>;
|
|
243
|
-
post<Path extends string, Handler extends LocalHandler<Schema, Instance, `${
|
|
244
|
-
path: Instance['path'];
|
|
236
|
+
post<Path extends string, Handler extends LocalHandler<Schema, Instance, `${BasePath}${Path}`>, Schema extends TypedSchema<Extract<keyof Instance['meta']['defs'], string>>>(path: Path, handler: Handler, hook?: LocalHook<Schema, Instance, `${BasePath}${Path}`>): Elysia<BasePath, {
|
|
245
237
|
request: Instance['request'];
|
|
246
238
|
store: Instance['store'];
|
|
247
239
|
schema: Instance['schema'];
|
|
248
240
|
error: Instance['error'];
|
|
249
241
|
meta: Record<'defs', Instance['meta']['defs']> & Record<'exposed', Instance['meta']['exposed']> & Record<'schema', Prettify<Instance['meta']['schema'] & (MergeSchema<Schema, Instance['schema']> extends infer Typed extends TypedSchema ? {
|
|
250
|
-
[path in
|
|
242
|
+
[path in Path]: {
|
|
251
243
|
post: {
|
|
252
244
|
handler?: Handler;
|
|
253
245
|
body: UnwrapSchema<Typed['body'], Instance['meta']['defs']>;
|
|
@@ -265,14 +257,13 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
265
257
|
};
|
|
266
258
|
} : {})>>;
|
|
267
259
|
}>;
|
|
268
|
-
put<Path extends string, Handler extends LocalHandler<Schema, Instance, `${
|
|
269
|
-
path: Instance['path'];
|
|
260
|
+
put<Path extends string, Handler extends LocalHandler<Schema, Instance, `${BasePath}${Path}`>, Schema extends TypedSchema<Extract<keyof Instance['meta']['defs'], string>>>(path: Path, handler: Handler, hook?: LocalHook<Schema, Instance, `${BasePath}${Path}`>): Elysia<BasePath, {
|
|
270
261
|
request: Instance['request'];
|
|
271
262
|
store: Instance['store'];
|
|
272
263
|
schema: Instance['schema'];
|
|
273
264
|
error: Instance['error'];
|
|
274
265
|
meta: Record<'defs', Instance['meta']['defs']> & Record<'exposed', Instance['meta']['exposed']> & Record<'schema', Prettify<Instance['meta']['schema'] & (MergeSchema<Schema, Instance['schema']> extends infer Typed extends TypedSchema ? {
|
|
275
|
-
[path in
|
|
266
|
+
[path in Path]: {
|
|
276
267
|
put: {
|
|
277
268
|
body: UnwrapSchema<Typed['body'], Instance['meta']['defs']>;
|
|
278
269
|
headers: UnwrapSchema<Typed['headers'], Instance['meta']['defs']> extends infer Result ? Result extends Record<string, any> ? Result : undefined : undefined;
|
|
@@ -289,14 +280,13 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
289
280
|
};
|
|
290
281
|
} : {})>>;
|
|
291
282
|
}>;
|
|
292
|
-
patch<Path extends string, Handler extends LocalHandler<Schema, Instance, `${
|
|
293
|
-
path: Instance['path'];
|
|
283
|
+
patch<Path extends string, Handler extends LocalHandler<Schema, Instance, `${BasePath}${Path}`>, Schema extends TypedSchema<Extract<keyof Instance['meta']['defs'], string>>>(path: Path, handler: Handler, hook?: LocalHook<Schema, Instance, `${BasePath}${Path}`>): Elysia<BasePath, {
|
|
294
284
|
request: Instance['request'];
|
|
295
285
|
store: Instance['store'];
|
|
296
286
|
schema: Instance['schema'];
|
|
297
287
|
error: Instance['error'];
|
|
298
288
|
meta: Record<'defs', Instance['meta']['defs']> & Record<'exposed', Instance['meta']['exposed']> & Record<'schema', Prettify<Instance['meta']['schema'] & (MergeSchema<Schema, Instance['schema']> extends infer Typed extends TypedSchema ? {
|
|
299
|
-
[path in
|
|
289
|
+
[path in Path]: {
|
|
300
290
|
patch: {
|
|
301
291
|
body: UnwrapSchema<Typed['body'], Instance['meta']['defs']>;
|
|
302
292
|
headers: UnwrapSchema<Typed['headers'], Instance['meta']['defs']> extends infer Result ? Result extends Record<string, any> ? Result : undefined : undefined;
|
|
@@ -313,14 +303,13 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
313
303
|
};
|
|
314
304
|
} : {})>>;
|
|
315
305
|
}>;
|
|
316
|
-
delete<Path extends string, Handler extends LocalHandler<Schema, Instance, `${
|
|
317
|
-
path: Instance['path'];
|
|
306
|
+
delete<Path extends string, Handler extends LocalHandler<Schema, Instance, `${BasePath}${Path}`>, Schema extends TypedSchema<Extract<keyof Instance['meta']['defs'], string>>>(path: Path, handler: Handler, hook?: LocalHook<Schema, Instance, `${BasePath}${Path}`>): Elysia<BasePath, {
|
|
318
307
|
request: Instance['request'];
|
|
319
308
|
store: Instance['store'];
|
|
320
309
|
schema: Instance['schema'];
|
|
321
310
|
error: Instance['error'];
|
|
322
311
|
meta: Record<'defs', Instance['meta']['defs']> & Record<'exposed', Instance['meta']['exposed']> & Record<'schema', Prettify<Instance['meta']['schema'] & (MergeSchema<Schema, Instance['schema']> extends infer Typed extends TypedSchema ? {
|
|
323
|
-
[path in
|
|
312
|
+
[path in Path]: {
|
|
324
313
|
delete: {
|
|
325
314
|
body: UnwrapSchema<Typed['body'], Instance['meta']['defs']>;
|
|
326
315
|
headers: UnwrapSchema<Typed['headers'], Instance['meta']['defs']> extends infer Result ? Result extends Record<string, any> ? Result : undefined : undefined;
|
|
@@ -337,14 +326,13 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
337
326
|
};
|
|
338
327
|
} : {})>>;
|
|
339
328
|
}>;
|
|
340
|
-
options<Path extends string, Handler extends LocalHandler<Schema, Instance, `${
|
|
341
|
-
path: Instance['path'];
|
|
329
|
+
options<Path extends string, Handler extends LocalHandler<Schema, Instance, `${BasePath}${Path}`>, Schema extends TypedSchema<Extract<keyof Instance['meta']['defs'], string>>>(path: Path, handler: Handler, hook?: LocalHook<Schema, Instance, `${BasePath}${Path}`>): Elysia<BasePath, {
|
|
342
330
|
request: Instance['request'];
|
|
343
331
|
store: Instance['store'];
|
|
344
332
|
schema: Instance['schema'];
|
|
345
333
|
error: Instance['error'];
|
|
346
334
|
meta: Record<'defs', Instance['meta']['defs']> & Record<'exposed', Instance['meta']['exposed']> & Record<'schema', Prettify<Instance['meta']['schema'] & (MergeSchema<Schema, Instance['schema']> extends infer Typed extends TypedSchema ? {
|
|
347
|
-
[path in
|
|
335
|
+
[path in Path]: {
|
|
348
336
|
options: {
|
|
349
337
|
body: UnwrapSchema<Typed['body'], Instance['meta']['defs']>;
|
|
350
338
|
headers: UnwrapSchema<Typed['headers'], Instance['meta']['defs']> extends infer Result ? Result extends Record<string, any> ? Result : undefined : undefined;
|
|
@@ -361,14 +349,13 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
361
349
|
};
|
|
362
350
|
} : {})>>;
|
|
363
351
|
}>;
|
|
364
|
-
all<Path extends string, Handler extends LocalHandler<Schema, Instance, `${
|
|
365
|
-
path: Instance['path'];
|
|
352
|
+
all<Path extends string, Handler extends LocalHandler<Schema, Instance, `${BasePath}${Path}`>, Schema extends TypedSchema<Extract<keyof Instance['meta']['defs'], string>>>(path: Path, handler: Handler, hook?: LocalHook<Schema, Instance, `${BasePath}${Path}`>): Elysia<BasePath, {
|
|
366
353
|
request: Instance['request'];
|
|
367
354
|
store: Instance['store'];
|
|
368
355
|
schema: Instance['schema'];
|
|
369
356
|
error: Instance['error'];
|
|
370
357
|
meta: Record<'defs', Instance['meta']['defs']> & Record<'exposed', Instance['meta']['exposed']> & Record<'schema', Prettify<Instance['meta']['schema'] & (MergeSchema<Schema, Instance['schema']> extends infer Typed extends TypedSchema ? {
|
|
371
|
-
[path in
|
|
358
|
+
[path in Path]: {
|
|
372
359
|
all: {
|
|
373
360
|
body: UnwrapSchema<Typed['body'], Instance['meta']['defs']>;
|
|
374
361
|
headers: UnwrapSchema<Typed['headers'], Instance['meta']['defs']> extends infer Result ? Result extends Record<string, any> ? Result : undefined : undefined;
|
|
@@ -385,14 +372,13 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
385
372
|
};
|
|
386
373
|
} : {})>>;
|
|
387
374
|
}>;
|
|
388
|
-
head<Path extends string, Handler extends LocalHandler<Schema, Instance, `${
|
|
389
|
-
path: Instance['path'];
|
|
375
|
+
head<Path extends string, Handler extends LocalHandler<Schema, Instance, `${BasePath}${Path}`>, Schema extends TypedSchema<Extract<keyof Instance['meta']['defs'], string>>>(path: Path, handler: Handler, hook?: LocalHook<Schema, Instance, `${BasePath}${Path}`>): Elysia<BasePath, {
|
|
390
376
|
request: Instance['request'];
|
|
391
377
|
store: Instance['store'];
|
|
392
378
|
schema: Instance['schema'];
|
|
393
379
|
error: Instance['error'];
|
|
394
380
|
meta: Record<'defs', Instance['meta']['defs']> & Record<'exposed', Instance['meta']['exposed']> & Record<'schema', Prettify<Instance['meta']['schema'] & (MergeSchema<Schema, Instance['schema']> extends infer Typed extends TypedSchema ? {
|
|
395
|
-
[path in
|
|
381
|
+
[path in Path]: {
|
|
396
382
|
head: {
|
|
397
383
|
body: UnwrapSchema<Typed['body'], Instance['meta']['defs']>;
|
|
398
384
|
headers: UnwrapSchema<Typed['headers'], Instance['meta']['defs']> extends infer Result ? Result extends Record<string, any> ? Result : undefined : undefined;
|
|
@@ -409,14 +395,13 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
409
395
|
};
|
|
410
396
|
} : {})>>;
|
|
411
397
|
}>;
|
|
412
|
-
trace<Path extends string, Handler extends LocalHandler<Schema, Instance, `${
|
|
413
|
-
path: Instance['path'];
|
|
398
|
+
trace<Path extends string, Handler extends LocalHandler<Schema, Instance, `${BasePath}${Path}`>, Schema extends TypedSchema<Extract<keyof Instance['meta']['defs'], string>>>(path: Path, handler: Handler, hook?: LocalHook<Schema, Instance, `${BasePath}${Path}`>): Elysia<BasePath, {
|
|
414
399
|
request: Instance['request'];
|
|
415
400
|
store: Instance['store'];
|
|
416
401
|
schema: Instance['schema'];
|
|
417
402
|
error: Instance['error'];
|
|
418
403
|
meta: Record<'defs', Instance['meta']['defs']> & Record<'exposed', Instance['meta']['exposed']> & Record<'schema', Prettify<Instance['meta']['schema'] & (MergeSchema<Schema, Instance['schema']> extends infer Typed extends TypedSchema ? {
|
|
419
|
-
[path in
|
|
404
|
+
[path in Path]: {
|
|
420
405
|
trace: {
|
|
421
406
|
body: UnwrapSchema<Typed['body'], Instance['meta']['defs']>;
|
|
422
407
|
headers: UnwrapSchema<Typed['headers'], Instance['meta']['defs']> extends infer Result ? Result extends Record<string, any> ? Result : undefined : undefined;
|
|
@@ -433,14 +418,13 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
433
418
|
};
|
|
434
419
|
} : {})>>;
|
|
435
420
|
}>;
|
|
436
|
-
connect<Path extends string, Handler extends LocalHandler<Schema, Instance, `${
|
|
437
|
-
path: Instance['path'];
|
|
421
|
+
connect<Path extends string, Handler extends LocalHandler<Schema, Instance, `${BasePath}${Path}`>, Schema extends TypedSchema<Extract<keyof Instance['meta']['defs'], string>>>(path: Path, handler: Handler, hook?: LocalHook<Schema, Instance, `${BasePath}${Path}`>): Elysia<BasePath, {
|
|
438
422
|
request: Instance['request'];
|
|
439
423
|
store: Instance['store'];
|
|
440
424
|
schema: Instance['schema'];
|
|
441
425
|
error: Instance['error'];
|
|
442
426
|
meta: Record<'defs', Instance['meta']['defs']> & Record<'exposed', Instance['meta']['exposed']> & Record<'schema', Prettify<Instance['meta']['schema'] & (MergeSchema<Schema, Instance['schema']> extends infer Typed extends TypedSchema ? {
|
|
443
|
-
[path in
|
|
427
|
+
[path in Path]: {
|
|
444
428
|
connect: {
|
|
445
429
|
body: UnwrapSchema<Typed['body'], Instance['meta']['defs']>;
|
|
446
430
|
headers: UnwrapSchema<Typed['headers'], Instance['meta']['defs']> extends infer Result ? Result extends Record<string, any> ? Result : undefined : undefined;
|
|
@@ -457,28 +441,26 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
457
441
|
};
|
|
458
442
|
} : {})>>;
|
|
459
443
|
}>;
|
|
460
|
-
ws<Path extends string, Schema extends WSTypedSchema<Extract<keyof Instance['meta']['defs'], string>>>(path: Path, options:
|
|
461
|
-
path: Instance['path'];
|
|
444
|
+
ws<Path extends string, Schema extends WSTypedSchema<Extract<keyof Instance['meta']['defs'], string>>>(path: Path, options: this extends Elysia<any, infer Instance> ? ElysiaWSOptions<`${BasePath}${Path}`, Schema, Instance['meta']['defs']> : never): Elysia<BasePath, {
|
|
462
445
|
request: Instance['request'];
|
|
463
446
|
store: Instance['store'];
|
|
464
447
|
schema: Instance['schema'];
|
|
465
448
|
error: Instance['error'];
|
|
466
|
-
meta: Instance['meta'] & Record<'schema', Record
|
|
467
|
-
subscribe: TypedWSRouteToEden<Typed, Instance['meta']['defs'], `${
|
|
449
|
+
meta: Instance['meta'] & Record<'schema', Record<Path, MergeSchema<Schema, Instance['schema']> extends infer Typed extends TypedSchema ? {
|
|
450
|
+
subscribe: TypedWSRouteToEden<Typed, Instance['meta']['defs'], `${BasePath}${Path}`>;
|
|
468
451
|
} : {}>>;
|
|
469
452
|
}>;
|
|
470
|
-
route<Schema extends TypedSchema<Exclude<keyof Instance['meta']['defs'], number | symbol>>, Method extends HTTPMethod, Path extends string, Handler extends LocalHandler<Schema, Instance, `${
|
|
453
|
+
route<Schema extends TypedSchema<Exclude<keyof Instance['meta']['defs'], number | symbol>>, Method extends HTTPMethod, Path extends string, Handler extends LocalHandler<Schema, Instance, `${BasePath}${Path}`>>(method: Method, path: Path, handler: Handler, { config, ...hook }?: LocalHook<Schema, Instance, `${BasePath}${Path}`> & {
|
|
471
454
|
config: {
|
|
472
455
|
allowMeta?: boolean;
|
|
473
456
|
};
|
|
474
|
-
}): Elysia<{
|
|
475
|
-
path: Instance['path'];
|
|
457
|
+
}): Elysia<BasePath, {
|
|
476
458
|
request: Instance['request'];
|
|
477
459
|
store: Instance['store'];
|
|
478
460
|
schema: Instance['schema'];
|
|
479
461
|
error: Instance['error'];
|
|
480
462
|
meta: Record<'defs', Instance['meta']['defs']> & Record<'exposed', Instance['meta']['exposed']> & Record<'schema', Prettify<Instance['meta']['schema'] & MergeSchema<Schema, Instance['schema']> extends infer Typed extends TypedSchema ? {
|
|
481
|
-
[path in
|
|
463
|
+
[path in Path]: {
|
|
482
464
|
[method in Method]: {
|
|
483
465
|
body: UnwrapSchema<Typed['body'], Instance['meta']['defs']>;
|
|
484
466
|
headers: UnwrapSchema<Typed['headers'], Instance['meta']['defs']> extends infer Result ? Result extends Record<string, any> ? Result : undefined : undefined;
|
|
@@ -495,32 +477,28 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
495
477
|
};
|
|
496
478
|
} : never>>;
|
|
497
479
|
}>;
|
|
498
|
-
state<Key extends string | number | symbol, Value>(name: Key, value: Value): Elysia<{
|
|
499
|
-
path: Instance['path'];
|
|
480
|
+
state<Key extends string | number | symbol, Value>(name: Key, value: Value): Elysia<BasePath, {
|
|
500
481
|
store: Reconciliation<Instance['store'], Record<Key, Value>>;
|
|
501
482
|
error: Instance['error'];
|
|
502
483
|
request: Instance['request'];
|
|
503
484
|
schema: Instance['schema'];
|
|
504
485
|
meta: Instance['meta'];
|
|
505
486
|
}>;
|
|
506
|
-
state<NewStore extends Record<string, unknown>>(store: NewStore): Elysia<{
|
|
507
|
-
path: Instance['path'];
|
|
487
|
+
state<NewStore extends Record<string, unknown>>(store: NewStore): Elysia<BasePath, {
|
|
508
488
|
store: Reconciliation<Instance['store'], DeepWritable<NewStore>>;
|
|
509
489
|
error: Instance['error'];
|
|
510
490
|
request: Instance['request'];
|
|
511
491
|
schema: Instance['schema'];
|
|
512
492
|
meta: Instance['meta'];
|
|
513
493
|
}>;
|
|
514
|
-
decorate<const Name extends string, const Value>(name: Name, value: Value): Elysia<{
|
|
515
|
-
path: Instance['path'];
|
|
494
|
+
decorate<const Name extends string, const Value>(name: Name, value: Value): Elysia<BasePath, {
|
|
516
495
|
store: Instance['store'];
|
|
517
496
|
error: Instance['error'];
|
|
518
497
|
request: Reconciliation<Instance['request'], Record<Name, Value>>;
|
|
519
498
|
schema: Instance['schema'];
|
|
520
499
|
meta: Instance['meta'];
|
|
521
500
|
}>;
|
|
522
|
-
decorate<const Decorators extends Record<string, unknown>>(name: Decorators): Elysia<{
|
|
523
|
-
path: Instance['path'];
|
|
501
|
+
decorate<const Decorators extends Record<string, unknown>>(name: Decorators): Elysia<BasePath, {
|
|
524
502
|
store: Instance['store'];
|
|
525
503
|
error: Instance['error'];
|
|
526
504
|
request: Reconciliation<Instance['request'], DeepWritable<Decorators>>;
|
|
@@ -529,16 +507,14 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
529
507
|
}>;
|
|
530
508
|
derive<Returned extends Object = Object>(transform: (context: Context<TypedSchemaToRoute<Instance['schema'], Instance['meta']['defs']>, Instance['store']> & Instance['request']) => MaybePromise<Returned> extends {
|
|
531
509
|
store: any;
|
|
532
|
-
} ? never : Returned): Elysia<{
|
|
533
|
-
path: Instance['path'];
|
|
510
|
+
} ? never : Returned): Elysia<BasePath, {
|
|
534
511
|
store: Instance['store'];
|
|
535
512
|
error: Instance['error'];
|
|
536
513
|
request: Instance['request'] & Awaited<Returned>;
|
|
537
514
|
schema: Instance['schema'];
|
|
538
515
|
meta: Instance['meta'];
|
|
539
516
|
}>;
|
|
540
|
-
schema<Schema extends TypedSchema<Exclude<keyof Instance['meta']['defs'], number | symbol>> = TypedSchema<Exclude<keyof Instance['meta']['defs'], number | symbol>>, NewInstance = Elysia<{
|
|
541
|
-
path: Instance['path'];
|
|
517
|
+
schema<Schema extends TypedSchema<Exclude<keyof Instance['meta']['defs'], number | symbol>> = TypedSchema<Exclude<keyof Instance['meta']['defs'], number | symbol>>, NewInstance = Elysia<BasePath, {
|
|
542
518
|
request: Instance['request'];
|
|
543
519
|
store: Instance['store'];
|
|
544
520
|
error: Instance['error'];
|
|
@@ -552,9 +528,8 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
552
528
|
private outerErrorHandler;
|
|
553
529
|
listen: (options: string | number | Partial<Serve>, callback?: ListenCallback) => this;
|
|
554
530
|
stop: () => Promise<void>;
|
|
555
|
-
get modules(): Promise<Elysia<any>[]>;
|
|
556
|
-
model<Name extends string, Model extends TSchema>(name: Name, model: Model): Elysia<{
|
|
557
|
-
path: Instance['path'];
|
|
531
|
+
get modules(): Promise<Elysia<any, any>[]>;
|
|
532
|
+
model<Name extends string, Model extends TSchema>(name: Name, model: Model): Elysia<BasePath, {
|
|
558
533
|
store: Instance['store'];
|
|
559
534
|
request: Instance['request'];
|
|
560
535
|
schema: Instance['schema'];
|
|
@@ -565,8 +540,7 @@ export default class Elysia<Instance extends ElysiaInstance = {
|
|
|
565
540
|
exposed: Instance['meta']['exposed'];
|
|
566
541
|
};
|
|
567
542
|
}>;
|
|
568
|
-
model<Recorder extends Record<string, TSchema>>(record: Recorder): Elysia<{
|
|
569
|
-
path: Instance['path'];
|
|
543
|
+
model<Recorder extends Record<string, TSchema>>(record: Recorder): Elysia<BasePath, {
|
|
570
544
|
store: Instance['store'];
|
|
571
545
|
request: Instance['request'];
|
|
572
546
|
schema: Instance['schema'];
|