elysia 1.0.7 → 1.0.9
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 +19 -36
- package/dist/bun/index.js +93 -90
- package/dist/bun/index.js.map +12 -12
- package/dist/cjs/compose.js +178 -19
- package/dist/cjs/cookies.js +28 -1
- package/dist/cjs/dynamic-handle.js +58 -18
- package/dist/cjs/error.js +28 -1
- package/dist/cjs/handler.d.ts +1 -1
- package/dist/cjs/handler.js +40 -6
- package/dist/cjs/index.d.ts +19 -36
- package/dist/cjs/index.js +221 -77
- package/dist/cjs/type-system.d.ts +16 -15
- package/dist/cjs/type-system.js +28 -1
- package/dist/cjs/types.d.ts +14 -2
- package/dist/cjs/utils.d.ts +12 -2
- package/dist/cjs/utils.js +91 -13
- package/dist/cjs/ws/index.js +28 -1
- package/dist/compose.mjs +178 -19
- package/dist/cookies.mjs +28 -1
- package/dist/dynamic-handle.mjs +58 -18
- package/dist/error.mjs +28 -1
- package/dist/handler.d.ts +1 -1
- package/dist/handler.mjs +40 -6
- package/dist/index.d.ts +19 -36
- package/dist/index.mjs +221 -77
- package/dist/type-system.d.ts +16 -15
- package/dist/type-system.mjs +28 -1
- package/dist/types.d.ts +14 -2
- package/dist/utils.d.ts +12 -2
- package/dist/utils.mjs +90 -13
- package/dist/ws/index.mjs +28 -1
- package/package.json +1 -1
- package/tsconfig.test.tsbuildinfo +1 -0
package/dist/bun/index.d.ts
CHANGED
|
@@ -7,9 +7,11 @@ import { Memoirist } from 'memoirist';
|
|
|
7
7
|
import { type Static, type TSchema } from '@sinclair/typebox';
|
|
8
8
|
import type { Context } from './context';
|
|
9
9
|
import { t } from './type-system';
|
|
10
|
+
import { type Sucrose } from './sucrose';
|
|
10
11
|
import type { WS } from './ws/types';
|
|
11
12
|
import { type DynamicHandler } from './dynamic-handle';
|
|
12
13
|
import type { ElysiaConfig, SingletonBase, DefinitionBase, ComposedHandler, InputSchema, LocalHook, MergeSchema, RouteSchema, UnwrapRoute, InternalRoute, HTTPMethod, SchemaValidator, VoidHandler, PreHandler, BodyHandler, OptionalHandler, AfterHandler, ErrorHandler, LifeCycleStore, MaybePromise, Prettify, Prettify2, ListenCallback, AddPrefix, AddSuffix, AddPrefixCapitalize, AddSuffixCapitalize, TraceHandler, MaybeArray, GracefulHandler, GetPathParameter, MapResponse, MacroManager, BaseMacro, MacroToProperty, TransformHandler, MetadataBase, RouteBase, CreateEden, ComposeElysiaResponse, InlineHandler, HookContainer, LifeCycleType, MacroQueue, EphemeralType, ExcludeElysiaResponse } from './types';
|
|
14
|
+
type AnyElysia = Elysia<any, any, any, any, any, any, any, any>;
|
|
13
15
|
/**
|
|
14
16
|
* ### Elysia Server
|
|
15
17
|
* Main instance to create web server using Elysia
|
|
@@ -21,7 +23,7 @@ import type { ElysiaConfig, SingletonBase, DefinitionBase, ComposedHandler, Inpu
|
|
|
21
23
|
*
|
|
22
24
|
* new Elysia()
|
|
23
25
|
* .get("/", () => "Hello")
|
|
24
|
-
* .listen(
|
|
26
|
+
* .listen(3000)
|
|
25
27
|
* ```
|
|
26
28
|
*/
|
|
27
29
|
export default class Elysia<const in out BasePath extends string = '', const in out Scoped extends boolean = false, const in out Singleton extends SingletonBase = {
|
|
@@ -93,27 +95,8 @@ export default class Elysia<const in out BasePath extends string = '', const in
|
|
|
93
95
|
history: InternalRoute[];
|
|
94
96
|
};
|
|
95
97
|
protected inference: {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
readonly cookie: false;
|
|
99
|
-
readonly headers: false;
|
|
100
|
-
readonly queries: [];
|
|
101
|
-
readonly query: false;
|
|
102
|
-
readonly set: false;
|
|
103
|
-
readonly unknownQueries: false;
|
|
104
|
-
};
|
|
105
|
-
readonly trace: {
|
|
106
|
-
readonly request: false;
|
|
107
|
-
readonly parse: false;
|
|
108
|
-
readonly transform: false;
|
|
109
|
-
readonly handle: false;
|
|
110
|
-
readonly beforeHandle: false;
|
|
111
|
-
readonly afterHandle: false;
|
|
112
|
-
readonly error: false;
|
|
113
|
-
readonly context: false;
|
|
114
|
-
readonly store: false;
|
|
115
|
-
readonly set: false;
|
|
116
|
-
};
|
|
98
|
+
event: Sucrose.Inference;
|
|
99
|
+
trace: Sucrose.TraceInference;
|
|
117
100
|
};
|
|
118
101
|
private promisedModules;
|
|
119
102
|
constructor(config?: ElysiaConfig<BasePath, Scoped>);
|
|
@@ -135,7 +118,7 @@ export default class Elysia<const in out BasePath extends string = '', const in
|
|
|
135
118
|
* .onStart(({ url, port }) => {
|
|
136
119
|
* console.log("Running at ${url}:${port}")
|
|
137
120
|
* })
|
|
138
|
-
* .listen(
|
|
121
|
+
* .listen(3000)
|
|
139
122
|
* ```
|
|
140
123
|
*/
|
|
141
124
|
onStart(handler: MaybeArray<GracefulHandler<this>>): this;
|
|
@@ -748,7 +731,7 @@ export default class Elysia<const in out BasePath extends string = '', const in
|
|
|
748
731
|
schema: {};
|
|
749
732
|
}>;
|
|
750
733
|
group<const Prefix extends string, const NewElysia extends Elysia<any, any, any, any, any, any, any, any>>(prefix: Prefix, run: (group: Elysia<`${BasePath}${Prefix}`, Scoped, Singleton, Definitions, Metadata, {}, Ephemeral, Volatile>) => NewElysia): Elysia<BasePath, Scoped, Singleton, Definitions, Metadata, Prettify<Routes & NewElysia['_routes']>, Ephemeral, Volatile>;
|
|
751
|
-
group<const Prefix extends string, const NewElysia extends
|
|
734
|
+
group<const Prefix extends string, const NewElysia extends AnyElysia, const Input extends InputSchema<Extract<keyof Definitions['type'], string>>, const Schema extends MergeSchema<UnwrapRoute<Input, Definitions['type']>, Metadata['schema']>>(prefix: Prefix, schema: LocalHook<Input, Schema, Singleton & {
|
|
752
735
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
753
736
|
resolve: Ephemeral['resolve'] & Volatile['resolve'];
|
|
754
737
|
}, Definitions['error'], Metadata['macro'], `${BasePath}${Prefix}`>, run: (group: Elysia<`${BasePath}${Prefix}`, false, Singleton, Definitions, {
|
|
@@ -763,11 +746,11 @@ export default class Elysia<const in out BasePath extends string = '', const in
|
|
|
763
746
|
resolve: Volatile['resolve'];
|
|
764
747
|
schema: MergeSchema<UnwrapRoute<LocalSchema, Definitions['type']>, Metadata['schema'] & Ephemeral['schema'] & Volatile['schema']>;
|
|
765
748
|
}>;
|
|
766
|
-
guard<const LocalSchema extends InputSchema<Extract<keyof Definitions['type'], string>>, const NewElysia extends
|
|
749
|
+
guard<const LocalSchema extends InputSchema<Extract<keyof Definitions['type'], string>>, const NewElysia extends AnyElysia, const Schema extends MergeSchema<UnwrapRoute<LocalSchema, Definitions['type']>, Metadata['schema']>>(run: (group: Elysia<BasePath, Scoped, Singleton, Definitions, {
|
|
767
750
|
schema: Prettify<Schema>;
|
|
768
751
|
macro: Metadata['macro'];
|
|
769
752
|
}, {}, Ephemeral, Volatile>) => NewElysia): Elysia<BasePath, Scoped, Singleton, Definitions, Metadata, Prettify<Routes & NewElysia['_routes']>, Ephemeral, Volatile>;
|
|
770
|
-
guard<const LocalSchema extends InputSchema<Extract<keyof Definitions['type'], string>>, const NewElysia extends
|
|
753
|
+
guard<const LocalSchema extends InputSchema<Extract<keyof Definitions['type'], string>>, const NewElysia extends AnyElysia, const Schema extends MergeSchema<UnwrapRoute<LocalSchema, Definitions['type']>, Metadata['schema']>>(schema: LocalHook<LocalSchema, Schema, Singleton & {
|
|
771
754
|
derive: Ephemeral['derive'] & Volatile['derive'];
|
|
772
755
|
resolve: Ephemeral['resolve'] & Volatile['resolve'];
|
|
773
756
|
}, Definitions['error'], Metadata['macro'], ''>, run: (group: Elysia<BasePath, Scoped, Singleton, Definitions, {
|
|
@@ -777,21 +760,21 @@ export default class Elysia<const in out BasePath extends string = '', const in
|
|
|
777
760
|
/**
|
|
778
761
|
* Inline fn
|
|
779
762
|
*/
|
|
780
|
-
use<const NewElysia extends
|
|
763
|
+
use<const NewElysia extends AnyElysia, const Param extends AnyElysia = this>(plugin: MaybePromise<(app: Param) => MaybePromise<NewElysia>>): NewElysia['_scoped'] extends false ? Elysia<BasePath, Scoped, Prettify2<Singleton & NewElysia['_types']['Singleton']>, Prettify2<Definitions & NewElysia['_types']['Definitions']>, Prettify2<Metadata & NewElysia['_types']['Metadata']>, BasePath extends `` ? Routes & NewElysia['_routes'] : Routes & CreateEden<BasePath, NewElysia['_routes']>, Prettify2<Ephemeral & NewElysia['_ephemeral']>, Prettify2<Volatile & NewElysia['_volatile']>> : Elysia<BasePath, Scoped, Singleton, Definitions, Metadata, BasePath extends `` ? Routes & NewElysia['_routes'] : Routes & CreateEden<BasePath, NewElysia['_routes']>, Ephemeral, Volatile>;
|
|
781
764
|
/**
|
|
782
765
|
* Entire Instance
|
|
783
766
|
**/
|
|
784
|
-
use<const NewElysia extends
|
|
767
|
+
use<const NewElysia extends AnyElysia>(instance: MaybePromise<NewElysia>): NewElysia['_scoped'] extends false ? Elysia<BasePath, Scoped, Prettify2<Singleton & NewElysia['_types']['Singleton']>, Prettify2<Definitions & NewElysia['_types']['Definitions']>, Prettify2<Metadata & NewElysia['_types']['Metadata']>, BasePath extends `` ? Routes & NewElysia['_routes'] : Routes & CreateEden<BasePath, NewElysia['_routes']>, Ephemeral, Prettify2<Volatile & NewElysia['_ephemeral']>> : Elysia<BasePath, Scoped, Singleton, Definitions, Metadata, BasePath extends `` ? Routes & NewElysia['_routes'] : Routes & CreateEden<BasePath, NewElysia['_routes']>, Ephemeral, Volatile>;
|
|
785
768
|
/**
|
|
786
769
|
* Import fn
|
|
787
770
|
*/
|
|
788
|
-
use<const NewElysia extends
|
|
789
|
-
default: (elysia:
|
|
771
|
+
use<const NewElysia extends AnyElysia>(plugin: Promise<{
|
|
772
|
+
default: (elysia: AnyElysia) => MaybePromise<NewElysia>;
|
|
790
773
|
}>): NewElysia['_scoped'] extends false ? Elysia<BasePath, Scoped, Prettify2<Singleton & NewElysia['_types']['Singleton']>, Prettify2<Definitions & NewElysia['_types']['Definitions']>, Prettify2<Metadata & NewElysia['_types']['Metadata']>, BasePath extends `` ? Routes & NewElysia['_routes'] : Routes & CreateEden<BasePath, NewElysia['_routes']>, Prettify2<Ephemeral & NewElysia['_ephemeral']>, Prettify2<Volatile & NewElysia['_volatile']>> : Elysia<BasePath, Scoped, Singleton, Definitions, Metadata, BasePath extends `` ? Routes & NewElysia['_routes'] : Routes & CreateEden<BasePath, NewElysia['_routes']>, Ephemeral, Volatile>;
|
|
791
774
|
/**
|
|
792
775
|
* Import entire instance
|
|
793
776
|
*/
|
|
794
|
-
use<const LazyLoadElysia extends
|
|
777
|
+
use<const LazyLoadElysia extends AnyElysia>(plugin: Promise<{
|
|
795
778
|
default: LazyLoadElysia;
|
|
796
779
|
}>): LazyLoadElysia['_scoped'] extends false ? Elysia<BasePath, Scoped, Prettify2<Singleton & LazyLoadElysia['_types']['Singleton']>, Prettify2<Definitions & LazyLoadElysia['_types']['Definitions']>, Prettify2<Metadata & LazyLoadElysia['_types']['Metadata']>, BasePath extends `` ? Routes & LazyLoadElysia['_routes'] : Routes & CreateEden<BasePath, LazyLoadElysia['_routes']>, Ephemeral, Prettify2<Volatile & LazyLoadElysia['_ephemeral']>> : Elysia<BasePath, Scoped, Singleton, Definitions, Metadata, BasePath extends `` ? Routes & LazyLoadElysia['_routes'] : Routes & CreateEden<BasePath, LazyLoadElysia['_routes']>, Ephemeral, Volatile>;
|
|
797
780
|
private _use;
|
|
@@ -802,8 +785,8 @@ export default class Elysia<const in out BasePath extends string = '', const in
|
|
|
802
785
|
schema: Metadata['schema'];
|
|
803
786
|
macro: Metadata['macro'] & Partial<MacroToProperty<NewMacro>>;
|
|
804
787
|
}, Routes, Ephemeral, Volatile>;
|
|
805
|
-
mount(handle: ((request: Request) => MaybePromise<Response>) |
|
|
806
|
-
mount(path: string, handle: ((request: Request) => MaybePromise<Response>) |
|
|
788
|
+
mount(handle: ((request: Request) => MaybePromise<Response>) | AnyElysia): this;
|
|
789
|
+
mount(path: string, handle: ((request: Request) => MaybePromise<Response>) | AnyElysia): this;
|
|
807
790
|
/**
|
|
808
791
|
* ### get
|
|
809
792
|
* Register handler for path with method [GET]
|
|
@@ -1397,7 +1380,7 @@ export default class Elysia<const in out BasePath extends string = '', const in
|
|
|
1397
1380
|
* ```typescript
|
|
1398
1381
|
* new Elysia()
|
|
1399
1382
|
* .get("/", () => 'hi')
|
|
1400
|
-
* .listen(
|
|
1383
|
+
* .listen(3000)
|
|
1401
1384
|
* ```
|
|
1402
1385
|
*/
|
|
1403
1386
|
listen: (options: string | number | Partial<Serve>, callback?: ListenCallback) => this;
|
|
@@ -1410,7 +1393,7 @@ export default class Elysia<const in out BasePath extends string = '', const in
|
|
|
1410
1393
|
* ```typescript
|
|
1411
1394
|
* const app = new Elysia()
|
|
1412
1395
|
* .get("/", () => 'hi')
|
|
1413
|
-
* .listen(
|
|
1396
|
+
* .listen(3000)
|
|
1414
1397
|
*
|
|
1415
1398
|
* // Sometime later
|
|
1416
1399
|
* app.stop()
|
|
@@ -1429,5 +1412,5 @@ export { Cookie, type CookieOptions } from './cookies';
|
|
|
1429
1412
|
export { getSchemaValidator, mergeHook, mergeObjectArray, getResponseSchemaValidator, StatusMap, InvertedStatusMap } from './utils';
|
|
1430
1413
|
export { error, ParseError, NotFoundError, ValidationError, InternalServerError, InvalidCookieSignature, ERROR_CODE, ELYSIA_RESPONSE } from './error';
|
|
1431
1414
|
export type { Context, PreContext } from './context';
|
|
1432
|
-
export type { EphemeralType, CreateEden, ComposeElysiaResponse, ElysiaConfig, SingletonBase, DefinitionBase, RouteBase, Handler, ComposedHandler, InputSchema, LocalHook, MergeSchema, RouteSchema, UnwrapRoute, InternalRoute, HTTPMethod, SchemaValidator, VoidHandler, PreHandler, BodyHandler, OptionalHandler, ErrorHandler, AfterHandler, LifeCycleEvent, TraceEvent, LifeCycleStore, LifeCycleType, MaybePromise, ListenCallback, UnwrapSchema, TraceHandler, TraceProcess, TraceReporter, TraceStream, Checksum } from './types';
|
|
1415
|
+
export type { EphemeralType, CreateEden, ComposeElysiaResponse, ElysiaConfig, SingletonBase, DefinitionBase, RouteBase, Handler, ComposedHandler, InputSchema, LocalHook, MergeSchema, RouteSchema, UnwrapRoute, InternalRoute, HTTPMethod, SchemaValidator, VoidHandler, PreHandler, BodyHandler, OptionalHandler, ErrorHandler, AfterHandler, LifeCycleEvent, TraceEvent, LifeCycleStore, LifeCycleType, MaybePromise, ListenCallback, UnwrapSchema, TraceHandler, TraceProcess, TraceReporter, TraceStream, Checksum, DocumentDecoration } from './types';
|
|
1433
1416
|
export type { Static, TSchema } from '@sinclair/typebox';
|