elysia 2.0.0-exp.18 → 2.0.0-exp.19
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/adapter/bun/index.d.ts +2 -25
- package/dist/adapter/bun/index.js +9 -8
- package/dist/adapter/bun/index.mjs +10 -9
- package/dist/adapter/constants.d.ts +3 -26
- package/dist/adapter/index.d.ts +1 -26
- package/dist/adapter/index.js +1 -17
- package/dist/adapter/index.mjs +1 -17
- package/dist/adapter/types.d.ts +1 -0
- package/dist/adapter/web-standard/index.d.ts +2 -26
- package/dist/adapter/web-standard/index.js +12 -1
- package/dist/adapter/web-standard/index.mjs +12 -1
- package/dist/base.js +9 -1
- package/dist/base.mjs +9 -1
- package/dist/compile/handler/jit.d.ts +1 -1
- package/dist/type/bridge.d.ts +7 -7
- package/dist/type/types.d.ts +1 -1
- package/dist/type/validator/index.d.ts +1 -1
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,30 +1,7 @@
|
|
|
1
|
-
import { ListenCallback, Serve } from "../../universal/server.js";
|
|
2
|
-
import { AnyLocalHook, MaybePromise } from "../../types.js";
|
|
3
|
-
import { Context } from "../../context.js";
|
|
4
1
|
import { AnyElysia } from "../../base.js";
|
|
2
|
+
import { ElysiaAdapterOptions } from "../types.js";
|
|
5
3
|
//#region src/adapter/bun/index.d.ts
|
|
6
4
|
declare function collectStaticRoutes(app: AnyElysia): readonly [Record<string, Record<string, Response>>, Promise<void>[]] | undefined;
|
|
7
|
-
declare const BunAdapter:
|
|
8
|
-
parse: {
|
|
9
|
-
default: (context: Context, contentType: string) => string | Record<string, unknown> | unknown[] | ArrayBuffer | Promise<unknown[] | Record<string | number | symbol, undefined>> | Promise<ArrayBuffer> | Promise<Record<string, unknown>> | Promise<string> | undefined;
|
|
10
|
-
json: (context: Context) => MaybePromise<Record<keyof any, undefined> | unknown[]>;
|
|
11
|
-
text: (context: Context) => MaybePromise<string>;
|
|
12
|
-
urlencoded: (context: Context) => MaybePromise<Record<string, string | string[]>>;
|
|
13
|
-
arrayBuffer: (context: Context) => MaybePromise<ArrayBuffer>;
|
|
14
|
-
formData: (context: Context) => MaybePromise<Record<string, unknown>>;
|
|
15
|
-
};
|
|
16
|
-
name: string;
|
|
17
|
-
runtime: "node" | "deno" | "bun" | "cloudflare-worker" | "browser" | "vercel" | "netlify" | "lambda" | "fastly" | "edge" | "unknown" | (string & {});
|
|
18
|
-
isWebStandard: boolean;
|
|
19
|
-
listen?(app: AnyElysia, options: string | number | Partial<Serve>, callback?: ListenCallback): void;
|
|
20
|
-
stop?(app: AnyElysia, closeActiveConnections?: boolean): Promise<void>;
|
|
21
|
-
response: {
|
|
22
|
-
map(response: unknown, set: Context["set"], ...params: unknown[]): unknown;
|
|
23
|
-
compact?(response: unknown, ...params: unknown[]): unknown;
|
|
24
|
-
static?(handle: unknown, hooks: AnyLocalHook, setHeaders?: Context["set"]["headers"], ...params: unknown[]): (() => unknown) | undefined;
|
|
25
|
-
nativeStatic?(handle: unknown, hooks: AnyLocalHook, set?: Context["set"]): (() => MaybePromise<Response>) | undefined;
|
|
26
|
-
};
|
|
27
|
-
fetch?(app: AnyElysia): (request: Request) => MaybePromise<Response>;
|
|
28
|
-
};
|
|
5
|
+
declare const BunAdapter: ElysiaAdapterOptions;
|
|
29
6
|
//#endregion
|
|
30
7
|
export { BunAdapter, collectStaticRoutes };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_adapter_index = require('../index.js');
|
|
3
|
+
const require_constants = require('../../constants.js');
|
|
3
4
|
const require_utils = require('../../utils.js');
|
|
4
5
|
const require_adapter_web_standard_index = require('../web-standard/index.js');
|
|
5
6
|
const require_memory = require('../../memory.js');
|
|
@@ -7,16 +8,13 @@ const require_ws_route = require('../../ws/route.js');
|
|
|
7
8
|
|
|
8
9
|
//#region src/adapter/bun/index.ts
|
|
9
10
|
function collectStaticRoutes(app) {
|
|
10
|
-
if (app["~ext"]?.hoc?.length) return;
|
|
11
|
-
const hook = require_utils.flattenChain(app["~hookChain"]);
|
|
12
|
-
if (hook && (hook?.request?.length || hook?.mapResponse?.length || hook?.afterResponse?.length || hook?.trace?.length)) return;
|
|
13
11
|
app.fetch;
|
|
14
12
|
const source = app["~staticResponse"];
|
|
15
13
|
if (!source) return;
|
|
16
14
|
const ready = require_utils.nullObject();
|
|
17
15
|
const pending = [];
|
|
18
16
|
for (const rawPath in source) {
|
|
19
|
-
const path = encodeURI(rawPath);
|
|
17
|
+
const path = require_constants.needEncodeRegex.test(rawPath) ? encodeURI(rawPath) : rawPath;
|
|
20
18
|
const methods = source[rawPath];
|
|
21
19
|
for (const method in methods) {
|
|
22
20
|
const value = methods[method];
|
|
@@ -31,24 +29,27 @@ function collectStaticRoutes(app) {
|
|
|
31
29
|
return [ready, pending];
|
|
32
30
|
}
|
|
33
31
|
const BunAdapter = require_adapter_index.createAdapter({
|
|
34
|
-
...require_adapter_web_standard_index.WebStandardAdapter,
|
|
35
32
|
name: "bun",
|
|
36
33
|
runtime: "bun",
|
|
34
|
+
isWebStandard: true,
|
|
35
|
+
parse: require_adapter_web_standard_index.WebStandardAdapter.parse,
|
|
36
|
+
response: require_adapter_web_standard_index.WebStandardAdapter.response,
|
|
37
37
|
listen(app, options, callback) {
|
|
38
38
|
const _config = app["~config"]?.serve;
|
|
39
|
-
const
|
|
39
|
+
const optionsIsObject = typeof options === "object";
|
|
40
|
+
const _options = optionsIsObject ? options : {
|
|
40
41
|
port: +options,
|
|
41
42
|
fetch: (request, server) => app.fetch(request, server)
|
|
42
43
|
};
|
|
44
|
+
if (optionsIsObject) _options.fetch = (request, server) => app.fetch(request, server);
|
|
43
45
|
const serve = _config ? {
|
|
44
46
|
..._config,
|
|
45
47
|
..._options
|
|
46
48
|
} : _options;
|
|
47
|
-
const hasWs = app["~hasWS"];
|
|
48
|
-
if (!serve.fetch) serve.fetch = (request, server) => app.fetch(request, server);
|
|
49
49
|
app.server = Bun.serve(serve);
|
|
50
50
|
const onSetup = app["~ext"]?.setup;
|
|
51
51
|
if (onSetup) for (let i = 0; i < onSetup.length; i++) onSetup[i](app);
|
|
52
|
+
const hasWs = app["~hasWS"];
|
|
52
53
|
if (!hasWs) callback?.(app.server);
|
|
53
54
|
queueMicrotask(() => {
|
|
54
55
|
if (!app.pending) serve.fetch = app.fetch;
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { createAdapter } from "../index.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { needEncodeRegex } from "../../constants.mjs";
|
|
3
|
+
import { nullObject } from "../../utils.mjs";
|
|
3
4
|
import { WebStandardAdapter } from "../web-standard/index.mjs";
|
|
4
5
|
import { flushMemory } from "../../memory.mjs";
|
|
5
6
|
import { buildGlobalWSHandler } from "../../ws/route.mjs";
|
|
6
7
|
|
|
7
8
|
//#region src/adapter/bun/index.ts
|
|
8
9
|
function collectStaticRoutes(app) {
|
|
9
|
-
if (app["~ext"]?.hoc?.length) return;
|
|
10
|
-
const hook = flattenChain(app["~hookChain"]);
|
|
11
|
-
if (hook && (hook?.request?.length || hook?.mapResponse?.length || hook?.afterResponse?.length || hook?.trace?.length)) return;
|
|
12
10
|
app.fetch;
|
|
13
11
|
const source = app["~staticResponse"];
|
|
14
12
|
if (!source) return;
|
|
15
13
|
const ready = nullObject();
|
|
16
14
|
const pending = [];
|
|
17
15
|
for (const rawPath in source) {
|
|
18
|
-
const path = encodeURI(rawPath);
|
|
16
|
+
const path = needEncodeRegex.test(rawPath) ? encodeURI(rawPath) : rawPath;
|
|
19
17
|
const methods = source[rawPath];
|
|
20
18
|
for (const method in methods) {
|
|
21
19
|
const value = methods[method];
|
|
@@ -30,24 +28,27 @@ function collectStaticRoutes(app) {
|
|
|
30
28
|
return [ready, pending];
|
|
31
29
|
}
|
|
32
30
|
const BunAdapter = createAdapter({
|
|
33
|
-
...WebStandardAdapter,
|
|
34
31
|
name: "bun",
|
|
35
32
|
runtime: "bun",
|
|
33
|
+
isWebStandard: true,
|
|
34
|
+
parse: WebStandardAdapter.parse,
|
|
35
|
+
response: WebStandardAdapter.response,
|
|
36
36
|
listen(app, options, callback) {
|
|
37
37
|
const _config = app["~config"]?.serve;
|
|
38
|
-
const
|
|
38
|
+
const optionsIsObject = typeof options === "object";
|
|
39
|
+
const _options = optionsIsObject ? options : {
|
|
39
40
|
port: +options,
|
|
40
41
|
fetch: (request, server) => app.fetch(request, server)
|
|
41
42
|
};
|
|
43
|
+
if (optionsIsObject) _options.fetch = (request, server) => app.fetch(request, server);
|
|
42
44
|
const serve = _config ? {
|
|
43
45
|
..._config,
|
|
44
46
|
..._options
|
|
45
47
|
} : _options;
|
|
46
|
-
const hasWs = app["~hasWS"];
|
|
47
|
-
if (!serve.fetch) serve.fetch = (request, server) => app.fetch(request, server);
|
|
48
48
|
app.server = Bun.serve(serve);
|
|
49
49
|
const onSetup = app["~ext"]?.setup;
|
|
50
50
|
if (onSetup) for (let i = 0; i < onSetup.length; i++) onSetup[i](app);
|
|
51
|
+
const hasWs = app["~hasWS"];
|
|
51
52
|
if (!hasWs) callback?.(app.server);
|
|
52
53
|
queueMicrotask(() => {
|
|
53
54
|
if (!app.pending) serve.fetch = app.fetch;
|
|
@@ -1,29 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { Context } from "../context.js";
|
|
4
|
-
import { AnyElysia } from "../base.js";
|
|
1
|
+
import { ElysiaAdapterOptions } from "./types.js";
|
|
2
|
+
|
|
5
3
|
//#region src/adapter/constants.d.ts
|
|
6
|
-
declare const defaultAdapter:
|
|
7
|
-
parse: {
|
|
8
|
-
default: (context: Context, contentType: string) => string | Record<string, unknown> | unknown[] | ArrayBuffer | Promise<unknown[] | Record<string | number | symbol, undefined>> | Promise<ArrayBuffer> | Promise<Record<string, unknown>> | Promise<string> | undefined;
|
|
9
|
-
json: (context: Context) => MaybePromise<Record<keyof any, undefined> | unknown[]>;
|
|
10
|
-
text: (context: Context) => MaybePromise<string>;
|
|
11
|
-
urlencoded: (context: Context) => MaybePromise<Record<string, string | string[]>>;
|
|
12
|
-
arrayBuffer: (context: Context) => MaybePromise<ArrayBuffer>;
|
|
13
|
-
formData: (context: Context) => MaybePromise<Record<string, unknown>>;
|
|
14
|
-
};
|
|
15
|
-
name: string;
|
|
16
|
-
runtime: "node" | "deno" | "bun" | "cloudflare-worker" | "browser" | "vercel" | "netlify" | "lambda" | "fastly" | "edge" | "unknown" | (string & {});
|
|
17
|
-
isWebStandard: boolean;
|
|
18
|
-
listen?(app: AnyElysia, options: string | number | Partial<Serve>, callback?: ListenCallback): void;
|
|
19
|
-
stop?(app: AnyElysia, closeActiveConnections?: boolean): Promise<void>;
|
|
20
|
-
response: {
|
|
21
|
-
map(response: unknown, set: Context["set"], ...params: unknown[]): unknown;
|
|
22
|
-
compact?(response: unknown, ...params: unknown[]): unknown;
|
|
23
|
-
static?(handle: unknown, hooks: AnyLocalHook, setHeaders?: Context["set"]["headers"], ...params: unknown[]): (() => unknown) | undefined;
|
|
24
|
-
nativeStatic?(handle: unknown, hooks: AnyLocalHook, set?: Context["set"]): (() => MaybePromise<Response>) | undefined;
|
|
25
|
-
};
|
|
26
|
-
fetch?(app: AnyElysia): (request: Request) => MaybePromise<Response>;
|
|
27
|
-
};
|
|
4
|
+
declare const defaultAdapter: ElysiaAdapterOptions;
|
|
28
5
|
//#endregion
|
|
29
6
|
export { defaultAdapter };
|
package/dist/adapter/index.d.ts
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
import { ListenCallback, Serve } from "../universal/server.js";
|
|
2
1
|
import { ElysiaAdapterOptions } from "./types.js";
|
|
3
|
-
import { AnyLocalHook, MaybePromise } from "../types.js";
|
|
4
|
-
import { Context } from "../context.js";
|
|
5
|
-
import { AnyElysia } from "../base.js";
|
|
6
2
|
|
|
7
3
|
//#region src/adapter/index.d.ts
|
|
8
|
-
declare function createAdapter(adapter: ElysiaAdapterOptions):
|
|
9
|
-
parse: {
|
|
10
|
-
default: (context: Context, contentType: string) => string | Record<string, unknown> | unknown[] | ArrayBuffer | Promise<unknown[] | Record<string | number | symbol, undefined>> | Promise<ArrayBuffer> | Promise<Record<string, unknown>> | Promise<string> | undefined;
|
|
11
|
-
json: (context: Context) => MaybePromise<Record<keyof any, undefined> | unknown[]>;
|
|
12
|
-
text: (context: Context) => MaybePromise<string>;
|
|
13
|
-
urlencoded: (context: Context) => MaybePromise<Record<string, string | string[]>>;
|
|
14
|
-
arrayBuffer: (context: Context) => MaybePromise<ArrayBuffer>;
|
|
15
|
-
formData: (context: Context) => MaybePromise<Record<string, unknown>>;
|
|
16
|
-
};
|
|
17
|
-
name: string;
|
|
18
|
-
runtime: "node" | "deno" | "bun" | "cloudflare-worker" | "browser" | "vercel" | "netlify" | "lambda" | "fastly" | "edge" | "unknown" | (string & {});
|
|
19
|
-
isWebStandard: boolean;
|
|
20
|
-
listen?(app: AnyElysia, options: string | number | Partial<Serve>, callback?: ListenCallback): void;
|
|
21
|
-
stop?(app: AnyElysia, closeActiveConnections?: boolean): Promise<void>;
|
|
22
|
-
response: {
|
|
23
|
-
map(response: unknown, set: Context["set"], ...params: unknown[]): unknown;
|
|
24
|
-
compact?(response: unknown, ...params: unknown[]): unknown;
|
|
25
|
-
static?(handle: unknown, hooks: AnyLocalHook, setHeaders?: Context["set"]["headers"], ...params: unknown[]): (() => unknown) | undefined;
|
|
26
|
-
nativeStatic?(handle: unknown, hooks: AnyLocalHook, set?: Context["set"]): (() => MaybePromise<Response>) | undefined;
|
|
27
|
-
};
|
|
28
|
-
fetch?(app: AnyElysia): (request: Request) => MaybePromise<Response>;
|
|
29
|
-
};
|
|
4
|
+
declare function createAdapter<const T extends ElysiaAdapterOptions>(adapter: ElysiaAdapterOptions): T;
|
|
30
5
|
type ElysiaAdapter = ReturnType<typeof createAdapter>;
|
|
31
6
|
//#endregion
|
|
32
7
|
export { ElysiaAdapter, type ElysiaAdapterOptions, createAdapter };
|
package/dist/adapter/index.js
CHANGED
|
@@ -2,23 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
//#region src/adapter/index.ts
|
|
4
4
|
function createAdapter(adapter) {
|
|
5
|
-
return
|
|
6
|
-
...adapter,
|
|
7
|
-
parse: {
|
|
8
|
-
...adapter.parse,
|
|
9
|
-
default: ((json, urlencoded, arrayBuffer, formData, text) => (context, contentType) => {
|
|
10
|
-
switch (contentType.charCodeAt(12)) {
|
|
11
|
-
case 106: return json(context);
|
|
12
|
-
case 120:
|
|
13
|
-
if (contentType.charCodeAt(13) === 45) return urlencoded(context);
|
|
14
|
-
break;
|
|
15
|
-
case 111: return arrayBuffer(context);
|
|
16
|
-
case 114: return formData(context);
|
|
17
|
-
default: if (contentType.charCodeAt(0) === 116) return text(context);
|
|
18
|
-
}
|
|
19
|
-
})(adapter.parse.json, adapter.parse.urlencoded, adapter.parse.arrayBuffer, adapter.parse.formData, adapter.parse.text)
|
|
20
|
-
}
|
|
21
|
-
};
|
|
5
|
+
return adapter;
|
|
22
6
|
}
|
|
23
7
|
|
|
24
8
|
//#endregion
|
package/dist/adapter/index.mjs
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
//#region src/adapter/index.ts
|
|
2
2
|
function createAdapter(adapter) {
|
|
3
|
-
return
|
|
4
|
-
...adapter,
|
|
5
|
-
parse: {
|
|
6
|
-
...adapter.parse,
|
|
7
|
-
default: ((json, urlencoded, arrayBuffer, formData, text) => (context, contentType) => {
|
|
8
|
-
switch (contentType.charCodeAt(12)) {
|
|
9
|
-
case 106: return json(context);
|
|
10
|
-
case 120:
|
|
11
|
-
if (contentType.charCodeAt(13) === 45) return urlencoded(context);
|
|
12
|
-
break;
|
|
13
|
-
case 111: return arrayBuffer(context);
|
|
14
|
-
case 114: return formData(context);
|
|
15
|
-
default: if (contentType.charCodeAt(0) === 116) return text(context);
|
|
16
|
-
}
|
|
17
|
-
})(adapter.parse.json, adapter.parse.urlencoded, adapter.parse.arrayBuffer, adapter.parse.formData, adapter.parse.text)
|
|
18
|
-
}
|
|
19
|
-
};
|
|
3
|
+
return adapter;
|
|
20
4
|
}
|
|
21
5
|
|
|
22
6
|
//#endregion
|
package/dist/adapter/types.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ interface ElysiaAdapterOptions {
|
|
|
45
45
|
urlencoded: (context: Context) => MaybePromise<Record<string, string | string[]>>;
|
|
46
46
|
arrayBuffer: (context: Context) => MaybePromise<ArrayBuffer>;
|
|
47
47
|
formData: (context: Context) => MaybePromise<Record<string, unknown>>;
|
|
48
|
+
default: (context: Context, contentType: string) => MaybePromise<any>;
|
|
48
49
|
};
|
|
49
50
|
response: {
|
|
50
51
|
/**
|
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AnyLocalHook, MaybePromise } from "../../types.js";
|
|
3
|
-
import { Context } from "../../context.js";
|
|
4
|
-
import { AnyElysia } from "../../base.js";
|
|
1
|
+
import { ElysiaAdapterOptions } from "../types.js";
|
|
5
2
|
//#region src/adapter/web-standard/index.d.ts
|
|
6
|
-
declare const WebStandardAdapter:
|
|
7
|
-
parse: {
|
|
8
|
-
default: (context: Context, contentType: string) => string | Record<string, unknown> | unknown[] | ArrayBuffer | Promise<unknown[] | Record<string | number | symbol, undefined>> | Promise<ArrayBuffer> | Promise<Record<string, unknown>> | Promise<string> | undefined;
|
|
9
|
-
json: (context: Context) => MaybePromise<Record<keyof any, undefined> | unknown[]>;
|
|
10
|
-
text: (context: Context) => MaybePromise<string>;
|
|
11
|
-
urlencoded: (context: Context) => MaybePromise<Record<string, string | string[]>>;
|
|
12
|
-
arrayBuffer: (context: Context) => MaybePromise<ArrayBuffer>;
|
|
13
|
-
formData: (context: Context) => MaybePromise<Record<string, unknown>>;
|
|
14
|
-
};
|
|
15
|
-
name: string;
|
|
16
|
-
runtime: "node" | "deno" | "bun" | "cloudflare-worker" | "browser" | "vercel" | "netlify" | "lambda" | "fastly" | "edge" | "unknown" | (string & {});
|
|
17
|
-
isWebStandard: boolean;
|
|
18
|
-
listen?(app: AnyElysia, options: string | number | Partial<Serve>, callback?: ListenCallback): void;
|
|
19
|
-
stop?(app: AnyElysia, closeActiveConnections?: boolean): Promise<void>;
|
|
20
|
-
response: {
|
|
21
|
-
map(response: unknown, set: Context["set"], ...params: unknown[]): unknown;
|
|
22
|
-
compact?(response: unknown, ...params: unknown[]): unknown;
|
|
23
|
-
static?(handle: unknown, hooks: AnyLocalHook, setHeaders?: Context["set"]["headers"], ...params: unknown[]): (() => unknown) | undefined;
|
|
24
|
-
nativeStatic?(handle: unknown, hooks: AnyLocalHook, set?: Context["set"]): (() => MaybePromise<Response>) | undefined;
|
|
25
|
-
};
|
|
26
|
-
fetch?(app: AnyElysia): (request: Request) => MaybePromise<Response>;
|
|
27
|
-
};
|
|
3
|
+
declare const WebStandardAdapter: ElysiaAdapterOptions;
|
|
28
4
|
//#endregion
|
|
29
5
|
export { WebStandardAdapter };
|
|
@@ -14,7 +14,18 @@ const WebStandardAdapter = require_adapter_index.createAdapter({
|
|
|
14
14
|
formData: (context) => context.request.formData().then(require_adapter_web_standard_utils.formDataToObject),
|
|
15
15
|
json: (context) => context.request.json(),
|
|
16
16
|
text: (context) => context.request.text(),
|
|
17
|
-
urlencoded: (context) => context.request.text().then(require_parse_query.parseQuery)
|
|
17
|
+
urlencoded: (context) => context.request.text().then(require_parse_query.parseQuery),
|
|
18
|
+
default(context, contentType) {
|
|
19
|
+
switch (contentType.charCodeAt(12)) {
|
|
20
|
+
case 106: return context.request.json();
|
|
21
|
+
case 120:
|
|
22
|
+
if (contentType.charCodeAt(13) === 45) return context.request.text().then(require_parse_query.parseQuery);
|
|
23
|
+
break;
|
|
24
|
+
case 111: return context.request.arrayBuffer();
|
|
25
|
+
case 114: return context.request.formData().then(require_adapter_web_standard_utils.formDataToObject);
|
|
26
|
+
default: if (contentType.charCodeAt(0) === 116) return context.request.text();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
18
29
|
},
|
|
19
30
|
response: {
|
|
20
31
|
map: require_adapter_web_standard_handler.mapResponse,
|
|
@@ -13,7 +13,18 @@ const WebStandardAdapter = createAdapter({
|
|
|
13
13
|
formData: (context) => context.request.formData().then(formDataToObject),
|
|
14
14
|
json: (context) => context.request.json(),
|
|
15
15
|
text: (context) => context.request.text(),
|
|
16
|
-
urlencoded: (context) => context.request.text().then(parseQuery)
|
|
16
|
+
urlencoded: (context) => context.request.text().then(parseQuery),
|
|
17
|
+
default(context, contentType) {
|
|
18
|
+
switch (contentType.charCodeAt(12)) {
|
|
19
|
+
case 106: return context.request.json();
|
|
20
|
+
case 120:
|
|
21
|
+
if (contentType.charCodeAt(13) === 45) return context.request.text().then(parseQuery);
|
|
22
|
+
break;
|
|
23
|
+
case 111: return context.request.arrayBuffer();
|
|
24
|
+
case 114: return context.request.formData().then(formDataToObject);
|
|
25
|
+
default: if (contentType.charCodeAt(0) === 116) return context.request.text();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
17
28
|
},
|
|
18
29
|
response: {
|
|
19
30
|
map: mapResponse,
|
package/dist/base.js
CHANGED
|
@@ -955,7 +955,15 @@ var Elysia = class Elysia {
|
|
|
955
955
|
if (maybeStatic) {
|
|
956
956
|
staticResponse = require_compile_handler_index.buildNativeStaticResponse(route, this);
|
|
957
957
|
if (staticResponse) {
|
|
958
|
-
const target = this["~staticResponse"] ??=
|
|
958
|
+
const target = this["~staticResponse"] ??= {
|
|
959
|
+
GET: void 0,
|
|
960
|
+
POST: void 0,
|
|
961
|
+
PUT: void 0,
|
|
962
|
+
DELETE: void 0,
|
|
963
|
+
PATCH: void 0,
|
|
964
|
+
HEAD: void 0,
|
|
965
|
+
OPTIONS: void 0
|
|
966
|
+
};
|
|
959
967
|
(target[path] ??= require_utils.nullObject())[method] = staticResponse;
|
|
960
968
|
if (!this["~config"]?.strictPath) {
|
|
961
969
|
const loose = require_utils.getLoosePath(path);
|
package/dist/base.mjs
CHANGED
|
@@ -952,7 +952,15 @@ var Elysia = class Elysia {
|
|
|
952
952
|
if (maybeStatic) {
|
|
953
953
|
staticResponse = buildNativeStaticResponse(route, this);
|
|
954
954
|
if (staticResponse) {
|
|
955
|
-
const target = this["~staticResponse"] ??=
|
|
955
|
+
const target = this["~staticResponse"] ??= {
|
|
956
|
+
GET: void 0,
|
|
957
|
+
POST: void 0,
|
|
958
|
+
PUT: void 0,
|
|
959
|
+
DELETE: void 0,
|
|
960
|
+
PATCH: void 0,
|
|
961
|
+
HEAD: void 0,
|
|
962
|
+
OPTIONS: void 0
|
|
963
|
+
};
|
|
956
964
|
(target[path] ??= nullObject())[method] = staticResponse;
|
|
957
965
|
if (!this["~config"]?.strictPath) {
|
|
958
966
|
const loose = getLoosePath(path);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ElysiaAdapter } from "../../adapter/index.js";
|
|
2
1
|
import { AnyLocalHook, CompiledHandler } from "../../types.js";
|
|
3
2
|
import { AnyElysia } from "../../base.js";
|
|
3
|
+
import { ElysiaAdapter } from "../../adapter/index.js";
|
|
4
4
|
import { RouteValidator } from "../../validator/route.js";
|
|
5
5
|
|
|
6
6
|
//#region src/compile/handler/jit.d.ts
|
package/dist/type/bridge.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Intersect as Intersect$
|
|
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 {
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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;
|
package/dist/type/types.d.ts
CHANGED
|
@@ -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'}`;
|
|
@@ -2,8 +2,8 @@ import { Validator as Validator$1, ValidatorOptions } from "../../validator/inde
|
|
|
2
2
|
import { TypeBoxValidatorCache } from "./validator-cache.js";
|
|
3
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
|
@@ -5,13 +5,13 @@ import { TraceEvent, TraceListener } from "./trace.js";
|
|
|
5
5
|
import { CookieOptions } from "./cookie/types.js";
|
|
6
6
|
import { AnySchema, StandardSchemaV1Like, TypeBoxSchema } from "./type/types.js";
|
|
7
7
|
import { Serve } from "./universal/server.js";
|
|
8
|
-
import { ElysiaAdapter } from "./adapter/index.js";
|
|
9
8
|
import { ChainNode } from "./utils.js";
|
|
10
9
|
import { Context, ErrorContext, LifecycleContext, PreContext } from "./context.js";
|
|
11
10
|
import { WebSocketHandler } from "./ws/types.js";
|
|
12
11
|
import { AnyElysia, Elysia } from "./base.js";
|
|
13
|
-
import {
|
|
12
|
+
import { ElysiaAdapter } from "./adapter/index.js";
|
|
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
|