elysia 1.0.6 → 1.0.7

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.
@@ -9,7 +9,7 @@ import type { Context } from './context';
9
9
  import { t } from './type-system';
10
10
  import type { WS } from './ws/types';
11
11
  import { type DynamicHandler } from './dynamic-handle';
12
- 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, LifeCycleType, MacroQueue, EphemeralType, ExcludeElysiaResponse } from './types';
12
+ 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';
13
13
  /**
14
14
  * ### Elysia Server
15
15
  * Main instance to create web server using Elysia
@@ -67,7 +67,7 @@ export default class Elysia<const in out BasePath extends string = '', const in
67
67
  error: Record<string, Error>;
68
68
  };
69
69
  protected extender: {
70
- macros: MacroQueue;
70
+ macros: MacroQueue[];
71
71
  };
72
72
  protected validator: SchemaValidator | null;
73
73
  event: LifeCycleStore;
@@ -120,6 +120,7 @@ export default class Elysia<const in out BasePath extends string = '', const in
120
120
  private getServer;
121
121
  get routes(): InternalRoute[];
122
122
  protected routeTree: Map<string, number>;
123
+ private applyMacro;
123
124
  private add;
124
125
  private setHeaders?;
125
126
  headers(header: Context['set']['headers'] | undefined): this;
@@ -721,7 +722,7 @@ export default class Elysia<const in out BasePath extends string = '', const in
721
722
  * })
722
723
  * ```
723
724
  */
724
- on<Event extends keyof LifeCycleStore>(type: Exclude<Event, 'onResponse'> | 'response', handlers: MaybeArray<Extract<LifeCycleStore[Event], Function[]>[0]>): this;
725
+ on<Event extends keyof LifeCycleStore>(type: Exclude<Event, 'onResponse'> | 'response', handlers: MaybeArray<Extract<LifeCycleStore[Event], HookContainer[]>[0]['fn']>): this;
725
726
  /**
726
727
  * ### on
727
728
  * Syntax sugar for attaching life cycle event by name
@@ -741,6 +742,11 @@ export default class Elysia<const in out BasePath extends string = '', const in
741
742
  on<const Event extends keyof LifeCycleStore>(options: {
742
743
  as?: LifeCycleType;
743
744
  }, type: Exclude<Event, 'onResponse'> | 'response', handlers: MaybeArray<Extract<LifeCycleStore[Event], Function[]>[0]>): this;
745
+ propagate(): Elysia<BasePath, Scoped, Singleton, Definitions, Metadata, Routes, Prettify2<Ephemeral & Volatile>, {
746
+ derive: {};
747
+ resolve: {};
748
+ schema: {};
749
+ }>;
744
750
  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>;
745
751
  group<const Prefix extends string, const NewElysia extends Elysia<any, any, any, any, any, any, any, any>, 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 & {
746
752
  derive: Ephemeral['derive'] & Volatile['derive'];
@@ -771,7 +777,7 @@ export default class Elysia<const in out BasePath extends string = '', const in
771
777
  /**
772
778
  * Inline fn
773
779
  */
774
- use<const NewElysia extends Elysia<any, any, any, any, any, any, any, any>, const Param extends Elysia<any, any, any, any, any, any, any, any> = 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']>, Prettify<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>;
780
+ use<const NewElysia extends Elysia<any, any, any, any, any, any, any, any>, const Param extends Elysia<any, any, any, any, any, any, any, any> = 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>;
775
781
  /**
776
782
  * Entire Instance
777
783
  **/
@@ -1423,5 +1429,5 @@ export { Cookie, type CookieOptions } from './cookies';
1423
1429
  export { getSchemaValidator, mergeHook, mergeObjectArray, getResponseSchemaValidator, StatusMap, InvertedStatusMap } from './utils';
1424
1430
  export { error, ParseError, NotFoundError, ValidationError, InternalServerError, InvalidCookieSignature, ERROR_CODE, ELYSIA_RESPONSE } from './error';
1425
1431
  export type { Context, PreContext } from './context';
1426
- export type { ElysiaFn, 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';
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';
1427
1433
  export type { Static, TSchema } from '@sinclair/typebox';