elysia 2.0.0-exp.21 → 2.0.0-exp.22

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.
@@ -11,7 +11,7 @@ declare function responseToSetHeaders(response: Response, set?: Context['set']):
11
11
  cookie?: Record<string, BaseCookie>;
12
12
  } | {
13
13
  headers: any;
14
- status: number | "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Bad Request" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required";
14
+ status: number | "Bad Request" | "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required";
15
15
  };
16
16
  interface CreateHandlerParameter {
17
17
  mapResponse(response: unknown, set: Context['set'], request?: Request): Response;
package/dist/base.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { ElysiaStatus } from "./error.js";
2
2
  import { TraceHandler } from "./trace.js";
3
+ import { AnySchema } from "./type/types.js";
3
4
  import { ListenCallback, Serve, Server } from "./universal/server.js";
4
5
  import { AddRoute, AddWSRoute, AfterHandler, AfterResponseHandler, AnyErrorConstructor, AnyLocalHook, BodyHandler, CompiledHandler, CreateEden, DefaultEphemeral, DefaultMetadata, DefaultSingleton, DefinitionBase, DocumentDecoration, ElysiaConfig, ElysiaHandlerToResponseSchemaAmbiguous, EphemeralType, ErrorDefinitionEntry, ErrorHandler, EventScope, ExcludeElysiaResponse, ExtractErrorFromHandle, GracefulHandler, GuardLocalHook, HTTPMethod, InlineHandler, InlineHandlerNonMacro, InputSchema, InputSchemaKey, InternalRoute, IntersectIfObjectSchema, JoinPath, LocalHook, Macro, MacroSchemaChannel, MacroToContext, MacroToProperty, MapResponse, MaybeArray, MaybePromise, MergeElysiaInstances, MergeSchema, MergeScopedSchemas, MetadataBase, NonResolvableMacroKey, ObjectMacroDefs, OptionalHandler, PreHandler, Prettify, PublicRoute, ResolveRouteErrors, RouteBase, SingletonBase, TransformHandler, UnionResponseStatus, UnwrapRoute, WrapFn } from "./types.js";
5
- import { AnySchema } from "./type/types.js";
6
6
  import { ChainNode } from "./utils.js";
7
7
  import { Context, ErrorContext, LifecycleContext } from "./context.js";
8
8
  import { WSHandlerResponse, WSLocalHook, WSMessageHandler } from "./ws/types.js";
package/dist/base.js CHANGED
@@ -38,7 +38,6 @@ var Elysia = class Elysia {
38
38
  }
39
39
  #compiled;
40
40
  #cachedRoutes;
41
- #hasMapResponse;
42
41
  constructor(config) {
43
42
  this["~config"] = config;
44
43
  this["~Prefix"] = config?.prefix;
@@ -213,7 +212,6 @@ var Elysia = class Elysia {
213
212
  return this.#onBranch("afterHandle", scopeOrFn, fn);
214
213
  }
215
214
  mapResponse(scopeOrFn, fn) {
216
- this.#hasMapResponse = true;
217
215
  return this.#onBranch("mapResponse", scopeOrFn, fn);
218
216
  }
219
217
  afterResponse(scopeOrFn, fn) {
@@ -534,7 +532,6 @@ var Elysia = class Elysia {
534
532
  }
535
533
  }
536
534
  const hookChain = app["~hookChain"];
537
- if (!this.#hasMapResponse && app.#hasMapResponse) this.#hasMapResponse = true;
538
535
  if (app["~ext"]) {
539
536
  const { decorator, store, headers, models, parser, macro, error, hoc, setup, cleanup } = app["~ext"];
540
537
  const ext = this["~ext"] ??= require_utils.nullObject();
@@ -902,9 +899,9 @@ var Elysia = class Elysia {
902
899
  for (let i = 0; i < length; i++) if (require_utils.mapMethodBack(this.#history[i][0]) === "HEAD") (explicitHead ??= /* @__PURE__ */ new Set()).add(this.#history[i][1]);
903
900
  }
904
901
  const wrapHeadHandler = Elysia.#wrapHeadHandler;
905
- const preferLoosePath = this["~config"]?.strictPath !== true;
902
+ const isLoose = this["~config"]?.strictPath !== true;
906
903
  let explicitPaths;
907
- if (preferLoosePath && this["~config"]?.distinctPath) {
904
+ if (isLoose && this["~config"]?.distinctPath) {
908
905
  explicitPaths = /* @__PURE__ */ new Map();
909
906
  for (let i = 0; i < length; i++) {
910
907
  const route = this.#history[i];
@@ -927,12 +924,12 @@ var Elysia = class Elysia {
927
924
  const ws = require_ws_route.buildWSRoute(route, this);
928
925
  const handler = ws[0];
929
926
  const options = ws[1];
930
- if (require_constants.isDynamicRegex.test(path)) (this["~router"] ??= new memoirist.default({ loosePath: preferLoosePath })).add("WS", path, handler, false);
927
+ if (require_constants.isDynamicRegex.test(path)) (this["~router"] ??= new memoirist.default({ loosePath: isLoose })).add("WS", path, handler, false);
931
928
  else {
932
929
  this.#initMap();
933
930
  const wsMap = this["~map"]["WS"] ??= require_utils.nullObject();
934
931
  wsMap[path] = handler;
935
- if (!this["~config"]?.strictPath) {
932
+ if (isLoose) {
936
933
  const loose = require_utils.getLoosePath(path);
937
934
  if (loose !== path && !explicitPaths?.get("WS")?.has(loose)) wsMap[loose] = handler;
938
935
  }
@@ -954,7 +951,7 @@ var Elysia = class Elysia {
954
951
  let staticResponse;
955
952
  const maybeStatic = buildStatic && typeof route[2] !== "function";
956
953
  if (maybeStatic) {
957
- staticResponse = require_compile_handler_index.buildNativeStaticResponse(route, this, this.#hasMapResponse);
954
+ staticResponse = require_compile_handler_index.buildNativeStaticResponse(route, this);
958
955
  if (staticResponse) {
959
956
  const target = this["~staticResponse"] ??= {
960
957
  GET: void 0,
@@ -975,7 +972,7 @@ var Elysia = class Elysia {
975
972
  const sharedStatic = maybeStatic && staticResponse instanceof Response ? staticResponse : void 0;
976
973
  const autoHead = enableAutoHead && method === "GET" && !explicitHead?.has(path);
977
974
  const isDynamic = require_constants.isDynamicRegex.test(path);
978
- const registerLoose = !isDynamic && preferLoosePath && (path.length === 0 || path.charCodeAt(path.length - 1) === 47);
975
+ const registerLoose = !isDynamic && isLoose && (path.length === 0 || path.charCodeAt(path.length - 1) === 47);
979
976
  const explicitMain = registerLoose ? explicitPaths?.get(method) : void 0;
980
977
  if (!isDynamic && !require_constants.needEncodeRegex.test(path) && !registerLoose) {
981
978
  const map = methods[method] ??= require_utils.nullObject();
@@ -1002,7 +999,7 @@ var Elysia = class Elysia {
1002
999
  }
1003
1000
  }
1004
1001
  if (isDynamic) {
1005
- const router = this["~router"] ??= new memoirist.default({ loosePath: preferLoosePath });
1002
+ const router = this["~router"] ??= new memoirist.default({ loosePath: isLoose });
1006
1003
  const handler = this.handler(i, precompile, void 0, sharedStatic);
1007
1004
  const headHandler = autoHead ? wrapHeadHandler(handler) : void 0;
1008
1005
  for (let p = 0; p < paths.length; p++) {
package/dist/base.mjs CHANGED
@@ -35,7 +35,6 @@ var Elysia = class Elysia {
35
35
  }
36
36
  #compiled;
37
37
  #cachedRoutes;
38
- #hasMapResponse;
39
38
  constructor(config) {
40
39
  this["~config"] = config;
41
40
  this["~Prefix"] = config?.prefix;
@@ -210,7 +209,6 @@ var Elysia = class Elysia {
210
209
  return this.#onBranch("afterHandle", scopeOrFn, fn);
211
210
  }
212
211
  mapResponse(scopeOrFn, fn) {
213
- this.#hasMapResponse = true;
214
212
  return this.#onBranch("mapResponse", scopeOrFn, fn);
215
213
  }
216
214
  afterResponse(scopeOrFn, fn) {
@@ -531,7 +529,6 @@ var Elysia = class Elysia {
531
529
  }
532
530
  }
533
531
  const hookChain = app["~hookChain"];
534
- if (!this.#hasMapResponse && app.#hasMapResponse) this.#hasMapResponse = true;
535
532
  if (app["~ext"]) {
536
533
  const { decorator, store, headers, models, parser, macro, error, hoc, setup, cleanup } = app["~ext"];
537
534
  const ext = this["~ext"] ??= nullObject();
@@ -899,9 +896,9 @@ var Elysia = class Elysia {
899
896
  for (let i = 0; i < length; i++) if (mapMethodBack(this.#history[i][0]) === "HEAD") (explicitHead ??= /* @__PURE__ */ new Set()).add(this.#history[i][1]);
900
897
  }
901
898
  const wrapHeadHandler = Elysia.#wrapHeadHandler;
902
- const preferLoosePath = this["~config"]?.strictPath !== true;
899
+ const isLoose = this["~config"]?.strictPath !== true;
903
900
  let explicitPaths;
904
- if (preferLoosePath && this["~config"]?.distinctPath) {
901
+ if (isLoose && this["~config"]?.distinctPath) {
905
902
  explicitPaths = /* @__PURE__ */ new Map();
906
903
  for (let i = 0; i < length; i++) {
907
904
  const route = this.#history[i];
@@ -924,12 +921,12 @@ var Elysia = class Elysia {
924
921
  const ws = buildWSRoute(route, this);
925
922
  const handler = ws[0];
926
923
  const options = ws[1];
927
- if (isDynamicRegex.test(path)) (this["~router"] ??= new Memoirist({ loosePath: preferLoosePath })).add("WS", path, handler, false);
924
+ if (isDynamicRegex.test(path)) (this["~router"] ??= new Memoirist({ loosePath: isLoose })).add("WS", path, handler, false);
928
925
  else {
929
926
  this.#initMap();
930
927
  const wsMap = this["~map"]["WS"] ??= nullObject();
931
928
  wsMap[path] = handler;
932
- if (!this["~config"]?.strictPath) {
929
+ if (isLoose) {
933
930
  const loose = getLoosePath(path);
934
931
  if (loose !== path && !explicitPaths?.get("WS")?.has(loose)) wsMap[loose] = handler;
935
932
  }
@@ -951,7 +948,7 @@ var Elysia = class Elysia {
951
948
  let staticResponse;
952
949
  const maybeStatic = buildStatic && typeof route[2] !== "function";
953
950
  if (maybeStatic) {
954
- staticResponse = buildNativeStaticResponse(route, this, this.#hasMapResponse);
951
+ staticResponse = buildNativeStaticResponse(route, this);
955
952
  if (staticResponse) {
956
953
  const target = this["~staticResponse"] ??= {
957
954
  GET: void 0,
@@ -972,7 +969,7 @@ var Elysia = class Elysia {
972
969
  const sharedStatic = maybeStatic && staticResponse instanceof Response ? staticResponse : void 0;
973
970
  const autoHead = enableAutoHead && method === "GET" && !explicitHead?.has(path);
974
971
  const isDynamic = isDynamicRegex.test(path);
975
- const registerLoose = !isDynamic && preferLoosePath && (path.length === 0 || path.charCodeAt(path.length - 1) === 47);
972
+ const registerLoose = !isDynamic && isLoose && (path.length === 0 || path.charCodeAt(path.length - 1) === 47);
976
973
  const explicitMain = registerLoose ? explicitPaths?.get(method) : void 0;
977
974
  if (!isDynamic && !needEncodeRegex.test(path) && !registerLoose) {
978
975
  const map = methods[method] ??= nullObject();
@@ -999,7 +996,7 @@ var Elysia = class Elysia {
999
996
  }
1000
997
  }
1001
998
  if (isDynamic) {
1002
- const router = this["~router"] ??= new Memoirist({ loosePath: preferLoosePath });
999
+ const router = this["~router"] ??= new Memoirist({ loosePath: isLoose });
1003
1000
  const handler = this.handler(i, precompile, void 0, sharedStatic);
1004
1001
  const headHandler = autoHead ? wrapHeadHandler(handler) : void 0;
1005
1002
  for (let p = 0; p < paths.length; p++) {
@@ -4,7 +4,7 @@ import { AnyElysia } from "../../base.js";
4
4
  import { setCaptureHeaderShorthand } from "./jit.js";
5
5
 
6
6
  //#region src/compile/handler/index.d.ts
7
- declare function buildNativeStaticResponse([,, handler, instance, localHook, appHook, inheritedChain]: InternalRoute, root: AnyElysia, hasMapResponse?: boolean): Response | Promise<Response> | undefined;
7
+ declare function buildNativeStaticResponse([,, handler, instance, localHook, appHook, inheritedChain]: InternalRoute, root: AnyElysia): Response | Promise<Response> | undefined;
8
8
  declare function composeRouteHook(instance: AnyElysia, localHook: Partial<AnyLocalHook> | undefined, appHook: ChainNode | undefined, inheritedChain: ChainNode | undefined, root: AnyElysia): AnyLocalHook | undefined;
9
9
  declare function compileHandler([_method, path, handler, instance, localHook, appHook, inheritedChain]: InternalRoute, root: AnyElysia, precomputedStatic?: Response): CompiledHandler;
10
10
  //#endregion
@@ -112,34 +112,38 @@ function composeRootHook(root, inheritedChain) {
112
112
  if (!locals) return inherited;
113
113
  return require_utils.mergeHook(inherited, locals);
114
114
  }
115
- function buildNativeStaticResponse([, , handler, instance, localHook, appHook, inheritedChain], root, hasMapResponse) {
115
+ function buildNativeStaticResponse([, , handler, instance, localHook, appHook, inheritedChain], root) {
116
116
  if (typeof handler === "function" || handler instanceof Error) return;
117
117
  const adapter = root["~config"]?.adapter ?? require_adapter_constants.defaultAdapter;
118
- if (hasMapResponse) {
119
- if (localHook) root["~applyMacro"](localHook);
120
- resolveChainMacros(root, appHook);
121
- if (inheritedChain) resolveChainMacros(root, inheritedChain);
122
- const hook = applyHook(localHook, require_utils.flattenChainMemo(root, appHook), instance !== root ? composeRootHook(root, inheritedChain) : void 0, true);
123
- if (hook?.mapResponse) {
124
- const context = new (require_context.createContext(root))(new Request("http://e.ly"));
125
- context.responseValue = handler;
126
- for (let i = 0; i < hook.mapResponse.length; i++) {
127
- const fn = hook.mapResponse[i];
128
- if (typeof fn !== "function") continue;
129
- const mapped = fn(context);
130
- if (mapped instanceof Response || mapped instanceof Promise) return mapped;
131
- }
132
- }
118
+ if (localHook) root["~applyMacro"](localHook);
119
+ resolveChainMacros(root, appHook);
120
+ if (inheritedChain) resolveChainMacros(root, inheritedChain);
121
+ const hook = applyHook(localHook, require_utils.flattenChainMemo(root, appHook), instance !== root ? composeRootHook(root, inheritedChain) : void 0, true);
122
+ if (hook) {
123
+ if (hook?.transform || hook?.beforeHandle || hook?.afterHandle) return;
124
+ if (hook?.body || hook?.query || hook?.params || hook?.headers || hook?.cookie || (hook?.schemas)?.length) return;
133
125
  }
134
126
  const rootHeaders = root["~ext"]?.headers;
135
- const buildSet = () => ({ headers: rootHeaders ? Object.assign(require_utils.nullObject(), rootHeaders) : require_utils.nullObject() });
127
+ const mapResponse = hook?.mapResponse ? (value) => {
128
+ const context = new (require_context.createContext(root))(new Request("http://e.ly"));
129
+ context.responseValue = value;
130
+ if (!Array.isArray(hook.mapResponse)) hook.mapResponse = [hook.mapResponse];
131
+ for (let i = 0; i < hook.mapResponse.length; i++) {
132
+ const fn = hook.mapResponse[i];
133
+ if (typeof fn !== "function") continue;
134
+ const mapped = fn(context);
135
+ if (mapped instanceof Response || mapped instanceof Promise) return mapped;
136
+ }
137
+ } : (value) => {
138
+ return adapter.response.map(value, { headers: rootHeaders ? Object.assign(require_utils.nullObject(), rootHeaders) : require_utils.nullObject() });
139
+ };
136
140
  if (handler instanceof Promise) return handler.then((resolved) => {
137
141
  if (resolved instanceof Response && !rootHeaders) return resolved;
138
- const mapped = adapter.response.map(resolved, buildSet());
142
+ const mapped = mapResponse(resolved);
139
143
  return mapped instanceof Response ? mapped : void 0;
140
144
  });
141
145
  if (handler instanceof Response && !rootHeaders) return handler;
142
- const mapped = adapter.response.map(handler, buildSet());
146
+ const mapped = mapResponse(handler);
143
147
  if (mapped instanceof Response || mapped instanceof Promise) return mapped;
144
148
  }
145
149
  function toArray(name, hook) {
@@ -111,34 +111,38 @@ function composeRootHook(root, inheritedChain) {
111
111
  if (!locals) return inherited;
112
112
  return mergeHook(inherited, locals);
113
113
  }
114
- function buildNativeStaticResponse([, , handler, instance, localHook, appHook, inheritedChain], root, hasMapResponse) {
114
+ function buildNativeStaticResponse([, , handler, instance, localHook, appHook, inheritedChain], root) {
115
115
  if (typeof handler === "function" || handler instanceof Error) return;
116
116
  const adapter = root["~config"]?.adapter ?? defaultAdapter;
117
- if (hasMapResponse) {
118
- if (localHook) root["~applyMacro"](localHook);
119
- resolveChainMacros(root, appHook);
120
- if (inheritedChain) resolveChainMacros(root, inheritedChain);
121
- const hook = applyHook(localHook, flattenChainMemo(root, appHook), instance !== root ? composeRootHook(root, inheritedChain) : void 0, true);
122
- if (hook?.mapResponse) {
123
- const context = new (createContext(root))(new Request("http://e.ly"));
124
- context.responseValue = handler;
125
- for (let i = 0; i < hook.mapResponse.length; i++) {
126
- const fn = hook.mapResponse[i];
127
- if (typeof fn !== "function") continue;
128
- const mapped = fn(context);
129
- if (mapped instanceof Response || mapped instanceof Promise) return mapped;
130
- }
131
- }
117
+ if (localHook) root["~applyMacro"](localHook);
118
+ resolveChainMacros(root, appHook);
119
+ if (inheritedChain) resolveChainMacros(root, inheritedChain);
120
+ const hook = applyHook(localHook, flattenChainMemo(root, appHook), instance !== root ? composeRootHook(root, inheritedChain) : void 0, true);
121
+ if (hook) {
122
+ if (hook?.transform || hook?.beforeHandle || hook?.afterHandle) return;
123
+ if (hook?.body || hook?.query || hook?.params || hook?.headers || hook?.cookie || (hook?.schemas)?.length) return;
132
124
  }
133
125
  const rootHeaders = root["~ext"]?.headers;
134
- const buildSet = () => ({ headers: rootHeaders ? Object.assign(nullObject(), rootHeaders) : nullObject() });
126
+ const mapResponse = hook?.mapResponse ? (value) => {
127
+ const context = new (createContext(root))(new Request("http://e.ly"));
128
+ context.responseValue = value;
129
+ if (!Array.isArray(hook.mapResponse)) hook.mapResponse = [hook.mapResponse];
130
+ for (let i = 0; i < hook.mapResponse.length; i++) {
131
+ const fn = hook.mapResponse[i];
132
+ if (typeof fn !== "function") continue;
133
+ const mapped = fn(context);
134
+ if (mapped instanceof Response || mapped instanceof Promise) return mapped;
135
+ }
136
+ } : (value) => {
137
+ return adapter.response.map(value, { headers: rootHeaders ? Object.assign(nullObject(), rootHeaders) : nullObject() });
138
+ };
135
139
  if (handler instanceof Promise) return handler.then((resolved) => {
136
140
  if (resolved instanceof Response && !rootHeaders) return resolved;
137
- const mapped = adapter.response.map(resolved, buildSet());
141
+ const mapped = mapResponse(resolved);
138
142
  return mapped instanceof Response ? mapped : void 0;
139
143
  });
140
144
  if (handler instanceof Response && !rootHeaders) return handler;
141
- const mapped = adapter.response.map(handler, buildSet());
145
+ const mapped = mapResponse(handler);
142
146
  if (mapped instanceof Response || mapped instanceof Promise) return mapped;
143
147
  }
144
148
  function toArray(name, hook) {
package/dist/error.d.ts CHANGED
@@ -85,7 +85,7 @@ declare class ElysiaStatus<const in out Code extends number | keyof StatusMap, T
85
85
  constructor(code: Code, res: T);
86
86
  get status(): number;
87
87
  }
88
- declare const status: <const Code extends number | keyof StatusMap, const T = (Code extends keyof StatusMapBack ? StatusMapBack[Code] : Code)>(code: Code, response?: T) => ElysiaStatus<Code, T, Code extends "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Bad Request" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required" ? {
88
+ declare const status: <const Code extends number | keyof StatusMap, const T = (Code extends keyof StatusMapBack ? StatusMapBack[Code] : Code)>(code: Code, response?: T) => ElysiaStatus<Code, T, Code extends "Bad Request" | "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required" ? {
89
89
  readonly Continue: 100;
90
90
  readonly 'Switching Protocols': 101;
91
91
  readonly Processing: 102;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,8 @@
1
1
  import { StatusMap, StatusMapBack } from "./constants.js";
2
2
  import { ElysiaError, ElysiaStatus, InternalServerError, InvalidCookieSignature, NotFound, ParseError, SelectiveStatus, ValidationError, status, validationDetail } from "./error.js";
3
+ import { ElysiaFile, file } from "./universal/file.js";
3
4
  import { BaseCookie, CookieOptions } from "./cookie/types.js";
4
5
  import { Cookie } from "./cookie/cookie.js";
5
- import { ElysiaFile, file } from "./universal/file.js";
6
- import { env } from "./universal/env.js";
7
- import { Server } from "./universal/server.js";
8
- import { HTTPHeaders, InputSchema, Macro, MacroToContext, MacroToProperty, RouteSchema, SSEPayload, UnwrapRoute, UnwrapSchema } from "./types.js";
9
6
  import { AnySchema, BaseSchema, StandardJSONSchemaV1Like, StandardSchemaV1Like } from "./type/types.js";
10
7
  import { TCookieField, TCookieObject } from "./type/elysia/cookie.js";
11
8
  import { FileTypeDetector, fileType, setFileTypeDetector } from "./type/elysia/file-type.js";
@@ -15,6 +12,9 @@ import { Capture, Compiled } from "./compile/aot.js";
15
12
  import { MultiValidator, StandardValidator, Validator } from "./validator/index.js";
16
13
  import { TypeBoxValidator } from "./type/validator/index.js";
17
14
  import { TypeSystem, t } from "./type/index.js";
15
+ import { env } from "./universal/env.js";
16
+ import { Server } from "./universal/server.js";
17
+ import { HTTPHeaders, InputSchema, Macro, MacroToContext, MacroToProperty, RouteSchema, SSEPayload, UnwrapRoute, UnwrapSchema } from "./types.js";
18
18
  import { form, prefix, redirect, sse } from "./utils.js";
19
19
  import { Context, ErrorContext, createBaseContext, createContext } from "./context.js";
20
20
  import { Elysia } from "./base.js";
@@ -1,16 +1,16 @@
1
- import { Intersect as Intersect$1 } from "./elysia/intersect.js";
1
+ import { Intersect as Intersect$2 } from "./elysia/intersect.js";
2
2
  import { applyCoercions as applyCoercions$1, coerceBody as coerceBody$1, coerceFormData as coerceFormData$1, coerceQuery as coerceQuery$1, coerceRoot as coerceRoot$1, coerceStringToStructure as coerceStringToStructure$1 } from "./coerce.js";
3
3
  import { hasTypes as hasTypes$1 } from "./utils.js";
4
4
  import { TypeBoxValidatorCache as TypeBoxValidatorCache$1 } from "./validator/validator-cache.js";
5
5
  import { TypeBoxValidator as TypeBoxValidator$1 } from "./validator/index.js";
6
- import { Ref as Ref$1, TAny, TSchema } from "typebox/type";
7
6
  import { Compile as Compile$1 } from "typebox/compile";
8
- import { Decode as Decode$1, Default as Default$1, HasCodec as HasCodec$1 } from "typebox/value";
7
+ import { Ref as Ref$1, TAny, TSchema } from "typebox/type";
8
+ import { Decode as Decode$2, Default as Default$1, HasCodec as HasCodec$1 } from "typebox/value";
9
9
 
10
10
  //#region src/type/bridge.d.ts
11
11
  interface TypeboxModule {
12
12
  Compile: typeof Compile$1;
13
- Decode: typeof Decode$1;
13
+ Decode: typeof Decode$2;
14
14
  applyCoercions: typeof applyCoercions$1;
15
15
  TypeBoxValidator: TypeBoxValidator$1;
16
16
  TypeBoxValidatorCache: TypeBoxValidatorCache$1;
@@ -21,12 +21,12 @@ interface TypeboxModule {
21
21
  coerceBody: typeof coerceBody$1;
22
22
  hasTypes: typeof hasTypes$1;
23
23
  HasCodec: typeof HasCodec$1;
24
- Intersect: typeof Intersect$1;
24
+ Intersect: typeof Intersect$2;
25
25
  Default: typeof Default$1;
26
26
  Ref: typeof Ref$1;
27
27
  }
28
28
  declare let Compile: typeof Compile$1;
29
- declare let Decode: typeof Decode$1;
29
+ declare let Decode: typeof Decode$2;
30
30
  declare let applyCoercions: typeof applyCoercions$1;
31
31
  declare let TypeBoxValidator: TypeBoxValidator$1;
32
32
  type TypeBoxValidator<T extends TSchema = TAny> = TypeBoxValidator$1<T>;
@@ -39,7 +39,7 @@ declare let coerceStringToStructure: typeof coerceStringToStructure$1;
39
39
  declare let coerceBody: typeof coerceBody$1;
40
40
  declare let hasTypes: typeof hasTypes$1;
41
41
  declare let HasCodec: typeof HasCodec$1;
42
- declare let Intersect: typeof Intersect$1;
42
+ declare let Intersect: typeof Intersect$2;
43
43
  declare let Default: typeof Default$1;
44
44
  declare let Ref: typeof Ref$1;
45
45
  declare function useTypebox(mod: TypeboxModule): void;
@@ -17,7 +17,7 @@ declare const ELYSIA_TYPES: {
17
17
  readonly NoValidate: 15;
18
18
  };
19
19
  type ELYSIA_TYPES = typeof ELYSIA_TYPES;
20
- declare const primitiveElysiaTypes: Set<1 | 2 | 3 | 6 | 10 | 11 | 13 | 14>;
20
+ declare const primitiveElysiaTypes: Set<3 | 1 | 2 | 6 | 10 | 11 | 13 | 14>;
21
21
  declare const noEnumerable: {
22
22
  readonly enumerable: false;
23
23
  };
@@ -1,5 +1,5 @@
1
- import { MaybeArray, MaybePromise } from "../../types.js";
2
1
  import { FileType, FileUnit } from "../types.js";
2
+ import { MaybeArray, MaybePromise } from "../../types.js";
3
3
 
4
4
  //#region src/type/elysia/file-type.d.ts
5
5
  type FileTypeDetector = (file: File) => MaybePromise<string | {
@@ -1,9 +1,9 @@
1
1
  import { ELYSIA_TYPES } from "./constants.js";
2
2
  import { CookieOptions } from "../cookie/types.js";
3
3
  import { MaybeArray } from "../types.js";
4
+ import { Validator } from "typebox/schema";
4
5
  import { TObjectOptions, TSchemaOptions } from "typebox";
5
6
  import { TLocalizedValidationError } from "typebox/error";
6
- import { Validator } from "typebox/schema";
7
7
 
8
8
  //#region src/type/types.d.ts
9
9
  type FileUnit = number | `${number}${'k' | 'm'}`;
@@ -1,9 +1,9 @@
1
- import { MaybePromise } from "../../types.js";
2
1
  import { Validator as Validator$1, ValidatorOptions } from "../../validator/index.js";
3
2
  import { TypeBoxValidatorCache } from "./validator-cache.js";
3
+ import { MaybePromise } from "../../types.js";
4
4
  import { Static, StaticDecode, StaticEncode, TAny, TSchema } from "typebox/type";
5
- import { TLocalizedValidationError } from "typebox/error";
6
5
  import { Validator } from "typebox/schema";
6
+ import { TLocalizedValidationError } from "typebox/error";
7
7
 
8
8
  //#region src/type/validator/index.d.ts
9
9
  declare function shallowMergeObjects(members: any[]): TSchema | null;
package/dist/types.d.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  import { MethodMap, StatusMapBack } from "./constants.js";
2
2
  import { ElysiaError, ElysiaStatus } from "./error.js";
3
- import { CookieOptions } from "./cookie/types.js";
4
3
  import { ElysiaFile } from "./universal/file.js";
5
4
  import { TraceEvent, TraceListener } from "./trace.js";
6
- import { Serve } from "./universal/server.js";
5
+ import { CookieOptions } from "./cookie/types.js";
7
6
  import { AnySchema, StandardSchemaV1Like, TypeBoxSchema } from "./type/types.js";
7
+ import { Serve } from "./universal/server.js";
8
8
  import { ChainNode } from "./utils.js";
9
9
  import { Context, ErrorContext, LifecycleContext, PreContext } from "./context.js";
10
10
  import { WebSocketHandler } from "./ws/types.js";
11
11
  import { AnyElysia, Elysia } from "./base.js";
12
12
  import { ElysiaAdapter } from "./adapter/index.js";
13
- import { Static, StaticDecode, StaticEncode, TIntersect, TObject, TSchema } from "typebox";
14
13
  import { Instruction } from "exact-mirror";
14
+ import { Static, StaticDecode, StaticEncode, TIntersect, TObject, TSchema } from "typebox";
15
15
  import { OpenAPIV3 } from "openapi-types";
16
16
 
17
17
  //#region src/types.d.ts
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { MethodMap } from "./constants.js";
2
- import { AnyLocalHook, AppHook, ElysiaFormData, EventFn, EventScope, GuardSchemaType, InputSchema, Macro, MaybeArray, Prettify, SSEPayload } from "./types.js";
3
2
  import { AnySchema, StandardSchemaV1Like } from "./type/types.js";
3
+ import { AnyLocalHook, AppHook, ElysiaFormData, EventFn, EventScope, GuardSchemaType, InputSchema, Macro, MaybeArray, Prettify, SSEPayload } from "./types.js";
4
4
  import { Context } from "./context.js";
5
5
 
6
6
  //#region src/utils.d.ts
@@ -1,8 +1,8 @@
1
- import { ElysiaConfig, MaybePromise } from "../types.js";
2
1
  import { AnySchema, StandardSchemaV1Like } from "../type/types.js";
3
2
  import { CoerceOption } from "../type/coerce.js";
4
3
  import { ValidatorSlot } from "../compile/aot.js";
5
4
  import { TypeBoxValidator } from "../type/bridge.js";
5
+ import { ElysiaConfig, MaybePromise } from "../types.js";
6
6
  import { TSchema } from "typebox/type";
7
7
  import { TLocalizedValidationError } from "typebox/error";
8
8
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "elysia",
3
3
  "description": "Ergonomic Framework for Human",
4
- "version": "2.0.0-exp.21",
4
+ "version": "2.0.0-exp.22",
5
5
  "author": {
6
6
  "name": "saltyAom",
7
7
  "url": "https://github.com/SaltyAom",