elysia 1.4.21 → 1.4.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.
- package/dist/adapter/bun/compose.js +1 -1
- package/dist/adapter/bun/compose.mjs +1 -1
- package/dist/adapter/bun/handler.js +87 -84
- package/dist/adapter/bun/handler.mjs +87 -84
- package/dist/adapter/bun/index.js +1 -1
- package/dist/adapter/bun/index.mjs +1 -1
- package/dist/adapter/utils.d.ts +3 -3
- package/dist/adapter/utils.js +11 -9
- package/dist/adapter/utils.mjs +11 -9
- package/dist/adapter/web-standard/handler.d.ts +4 -2
- package/dist/adapter/web-standard/handler.js +94 -86
- package/dist/adapter/web-standard/handler.mjs +94 -86
- package/dist/bun/index.js +10 -10
- package/dist/bun/index.js.map +13 -13
- package/dist/compose.js +11 -3
- package/dist/compose.mjs +11 -3
- package/dist/dynamic-handle.js +2 -1
- package/dist/dynamic-handle.mjs +2 -1
- package/dist/error.d.ts +7 -11
- package/dist/error.js +2 -5
- package/dist/error.mjs +2 -5
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/type-system/index.js +1 -1
- package/dist/type-system/index.mjs +1 -1
- package/dist/utils.js +2 -2
- package/dist/utils.mjs +2 -2
- package/package.json +1 -1
package/dist/compose.js
CHANGED
|
@@ -178,9 +178,17 @@ c.set.status=${status2}
|
|
|
178
178
|
}, hasReturn = (v) => {
|
|
179
179
|
const isObject = typeof v == "object";
|
|
180
180
|
if (isObject && v.hasReturn !== void 0) return v.hasReturn;
|
|
181
|
-
const fnLiteral = isObject ? v.fn.toString() :
|
|
182
|
-
if (
|
|
183
|
-
|
|
181
|
+
const fnLiteral = isObject ? v.fn.toString() : v.toString(), parenthesisEnd = fnLiteral.indexOf(")"), arrowIndex = fnLiteral.indexOf("=>", parenthesisEnd);
|
|
182
|
+
if (arrowIndex !== -1) {
|
|
183
|
+
let afterArrow = arrowIndex + 2, charCode;
|
|
184
|
+
for (; afterArrow < fnLiteral.length && ((charCode = fnLiteral.charCodeAt(afterArrow)) === 32 || // space
|
|
185
|
+
charCode === 9 || // tab
|
|
186
|
+
charCode === 10 || // newline
|
|
187
|
+
charCode === 13); )
|
|
188
|
+
afterArrow++;
|
|
189
|
+
if (afterArrow < fnLiteral.length && fnLiteral.charCodeAt(afterArrow) !== 123)
|
|
190
|
+
return isObject && (v.hasReturn = !0), !0;
|
|
191
|
+
}
|
|
184
192
|
const result = fnLiteral.includes("return");
|
|
185
193
|
return isObject && (v.hasReturn = result), result;
|
|
186
194
|
}, isGenerator = (v) => {
|
package/dist/compose.mjs
CHANGED
|
@@ -190,9 +190,17 @@ c.set.status=${status2}
|
|
|
190
190
|
}, hasReturn = (v) => {
|
|
191
191
|
const isObject = typeof v == "object";
|
|
192
192
|
if (isObject && v.hasReturn !== void 0) return v.hasReturn;
|
|
193
|
-
const fnLiteral = isObject ? v.fn.toString() :
|
|
194
|
-
if (
|
|
195
|
-
|
|
193
|
+
const fnLiteral = isObject ? v.fn.toString() : v.toString(), parenthesisEnd = fnLiteral.indexOf(")"), arrowIndex = fnLiteral.indexOf("=>", parenthesisEnd);
|
|
194
|
+
if (arrowIndex !== -1) {
|
|
195
|
+
let afterArrow = arrowIndex + 2, charCode;
|
|
196
|
+
for (; afterArrow < fnLiteral.length && ((charCode = fnLiteral.charCodeAt(afterArrow)) === 32 || // space
|
|
197
|
+
charCode === 9 || // tab
|
|
198
|
+
charCode === 10 || // newline
|
|
199
|
+
charCode === 13); )
|
|
200
|
+
afterArrow++;
|
|
201
|
+
if (afterArrow < fnLiteral.length && fnLiteral.charCodeAt(afterArrow) !== 123)
|
|
202
|
+
return isObject && (v.hasReturn = !0), !0;
|
|
203
|
+
}
|
|
196
204
|
const result = fnLiteral.includes("return");
|
|
197
205
|
return isObject && (v.hasReturn = result), result;
|
|
198
206
|
}, isGenerator = (v) => {
|
package/dist/dynamic-handle.js
CHANGED
|
@@ -60,7 +60,8 @@ const injectDefaultValues = (typeChecker, obj) => {
|
|
|
60
60
|
if (!handler)
|
|
61
61
|
throw context.query = qi === -1 ? {} : (0, import_parse_query.parseQuery)(url.substring(qi + 1)), new import_error.NotFoundError();
|
|
62
62
|
const { handle, validator, content, route } = handler.store;
|
|
63
|
-
hooks = handler.store.hooks
|
|
63
|
+
if (hooks = handler.store.hooks, hooks.config?.mount)
|
|
64
|
+
return await hooks.config.mount(request);
|
|
64
65
|
let body;
|
|
65
66
|
if (request.method !== "GET" && request.method !== "HEAD")
|
|
66
67
|
if (content)
|
package/dist/dynamic-handle.mjs
CHANGED
|
@@ -48,7 +48,8 @@ const injectDefaultValues = (typeChecker, obj) => {
|
|
|
48
48
|
if (!handler)
|
|
49
49
|
throw context.query = qi === -1 ? {} : parseQuery(url.substring(qi + 1)), new NotFoundError();
|
|
50
50
|
const { handle, validator, content, route } = handler.store;
|
|
51
|
-
hooks = handler.store.hooks
|
|
51
|
+
if (hooks = handler.store.hooks, hooks.config?.mount)
|
|
52
|
+
return await hooks.config.mount(request);
|
|
52
53
|
let body;
|
|
53
54
|
if (request.method !== "GET" && request.method !== "HEAD")
|
|
54
55
|
if (content)
|
package/dist/error.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { TSchema } from '@sinclair/typebox';
|
|
|
2
2
|
import type { TypeCheck, ValueError, ValueErrorIterator } from '@sinclair/typebox/compiler';
|
|
3
3
|
import { StatusMap, InvertedStatusMap } from './utils';
|
|
4
4
|
import type { ElysiaTypeCheck } from './schema';
|
|
5
|
-
import {
|
|
5
|
+
import { StandardSchemaV1Like } from './types';
|
|
6
6
|
export declare const ERROR_CODE: unique symbol;
|
|
7
7
|
export type ERROR_CODE = typeof ERROR_CODE;
|
|
8
8
|
export declare const isProduction: boolean;
|
|
@@ -102,14 +102,10 @@ export declare class InvalidCookieSignature extends Error {
|
|
|
102
102
|
status: number;
|
|
103
103
|
constructor(key: string, message?: string);
|
|
104
104
|
}
|
|
105
|
-
|
|
106
|
-
summary
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
} | Prettify<{
|
|
110
|
-
summary: string;
|
|
111
|
-
} & ValueError>;
|
|
112
|
-
export declare const mapValueError: (error: ValueError | undefined) => MapValueError;
|
|
105
|
+
interface ValueErrorWithSummary extends ValueError {
|
|
106
|
+
summary?: string;
|
|
107
|
+
}
|
|
108
|
+
export declare const mapValueError: (error: ValueError) => ValueErrorWithSummary;
|
|
113
109
|
export declare class InvalidFileType extends Error {
|
|
114
110
|
property: string;
|
|
115
111
|
expected: string | string[];
|
|
@@ -153,7 +149,7 @@ export declare class ValidationError extends Error {
|
|
|
153
149
|
* Input value
|
|
154
150
|
*/
|
|
155
151
|
value: unknown, allowUnsafeValidationDetails?: boolean, errors?: ValueErrorIterator);
|
|
156
|
-
get all():
|
|
152
|
+
get all(): ValueErrorWithSummary[];
|
|
157
153
|
static simplifyModel(validator: TSchema | TypeCheck<any> | ElysiaTypeCheck<any>): any;
|
|
158
154
|
get model(): any;
|
|
159
155
|
toResponse(headers?: Record<string, any>): Response;
|
|
@@ -194,7 +190,7 @@ export declare class ValidationError extends Error {
|
|
|
194
190
|
summary: string | undefined;
|
|
195
191
|
found: unknown;
|
|
196
192
|
expected: unknown;
|
|
197
|
-
errors:
|
|
193
|
+
errors: ValueErrorWithSummary[];
|
|
198
194
|
};
|
|
199
195
|
}
|
|
200
196
|
export {};
|
package/dist/error.js
CHANGED
|
@@ -79,10 +79,7 @@ class InvalidCookieSignature extends Error {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
const mapValueError = (error) => {
|
|
82
|
-
if (!error)
|
|
83
|
-
return {
|
|
84
|
-
summary: void 0
|
|
85
|
-
};
|
|
82
|
+
if (!error) return error;
|
|
86
83
|
let { message, path, value, type } = error;
|
|
87
84
|
Array.isArray(path) && (path = path[0]);
|
|
88
85
|
const property = typeof path == "string" ? path.slice(1).replaceAll("/", ".") : "unknown", isRoot = path === "";
|
|
@@ -344,7 +341,7 @@ class ValidationError extends Error {
|
|
|
344
341
|
on: this.type,
|
|
345
342
|
property: this.valueError?.path || "root",
|
|
346
343
|
message,
|
|
347
|
-
summary: mapValueError(this.valueError).summary,
|
|
344
|
+
summary: this.valueError ? mapValueError(this.valueError).summary : void 0,
|
|
348
345
|
found: value,
|
|
349
346
|
expected,
|
|
350
347
|
errors
|
package/dist/error.mjs
CHANGED
|
@@ -50,10 +50,7 @@ class InvalidCookieSignature extends Error {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
const mapValueError = (error) => {
|
|
53
|
-
if (!error)
|
|
54
|
-
return {
|
|
55
|
-
summary: void 0
|
|
56
|
-
};
|
|
53
|
+
if (!error) return error;
|
|
57
54
|
let { message, path, value, type } = error;
|
|
58
55
|
Array.isArray(path) && (path = path[0]);
|
|
59
56
|
const property = typeof path == "string" ? path.slice(1).replaceAll("/", ".") : "unknown", isRoot = path === "";
|
|
@@ -315,7 +312,7 @@ class ValidationError extends Error {
|
|
|
315
312
|
on: this.type,
|
|
316
313
|
property: this.valueError?.path || "root",
|
|
317
314
|
message,
|
|
318
|
-
summary: mapValueError(this.valueError).summary,
|
|
315
|
+
summary: this.valueError ? mapValueError(this.valueError).summary : void 0,
|
|
319
316
|
found: value,
|
|
320
317
|
expected,
|
|
321
318
|
errors
|
package/dist/index.js
CHANGED
|
@@ -1430,7 +1430,7 @@ const _Elysia = class _Elysia {
|
|
|
1430
1430
|
}
|
|
1431
1431
|
const handle = handleOrConfig instanceof _Elysia ? handleOrConfig.compile().fetch : typeof handleOrConfig == "function" ? handleOrConfig : (() => {
|
|
1432
1432
|
throw new Error("Invalid handler");
|
|
1433
|
-
})(), length = path.length - (path.endsWith("*") ? 1 : 0), handler = ({ request, path: path2 }) => handle(
|
|
1433
|
+
})(), length = (typeof path == "string" && this.config.prefix ? this.config.prefix + path : path).length - (path.endsWith("*") ? 1 : 0), handler = ({ request, path: path2 }) => handle(
|
|
1434
1434
|
new Request(
|
|
1435
1435
|
(0, import_utils2.replaceUrlPath)(request.url, path2.slice(length) || "/"),
|
|
1436
1436
|
{
|
package/dist/index.mjs
CHANGED
|
@@ -1429,7 +1429,7 @@ const _Elysia = class _Elysia {
|
|
|
1429
1429
|
}
|
|
1430
1430
|
const handle = handleOrConfig instanceof _Elysia ? handleOrConfig.compile().fetch : typeof handleOrConfig == "function" ? handleOrConfig : (() => {
|
|
1431
1431
|
throw new Error("Invalid handler");
|
|
1432
|
-
})(), length = path.length - (path.endsWith("*") ? 1 : 0), handler = ({ request, path: path2 }) => handle(
|
|
1432
|
+
})(), length = (typeof path == "string" && this.config.prefix ? this.config.prefix + path : path).length - (path.endsWith("*") ? 1 : 0), handler = ({ request, path: path2 }) => handle(
|
|
1433
1433
|
new Request(
|
|
1434
1434
|
replaceUrlPath(request.url, path2.slice(length) || "/"),
|
|
1435
1435
|
{
|
|
@@ -250,7 +250,7 @@ const internalFiles = (0, import_utils.createType)(
|
|
|
250
250
|
});
|
|
251
251
|
},
|
|
252
252
|
ArrayQuery: (children = t.String(), options) => {
|
|
253
|
-
const schema = t.Array(children, options), compiler = (0, import_utils.compile)(schema), decode = (value) => value.indexOf(",") !== -1 ? compiler.Decode(value.split(",")) : [value];
|
|
253
|
+
const schema = t.Array(children, options), compiler = (0, import_utils.compile)(schema), decode = (value) => value.indexOf(",") !== -1 ? compiler.Decode(value.split(",")) : compiler.Decode([value]);
|
|
254
254
|
return t.Transform(
|
|
255
255
|
t.Union(
|
|
256
256
|
[
|
|
@@ -231,7 +231,7 @@ const internalFiles = createType(
|
|
|
231
231
|
});
|
|
232
232
|
},
|
|
233
233
|
ArrayQuery: (children = t.String(), options) => {
|
|
234
|
-
const schema = t.Array(children, options), compiler = compile(schema), decode = (value) => value.indexOf(",") !== -1 ? compiler.Decode(value.split(",")) : [value];
|
|
234
|
+
const schema = t.Array(children, options), compiler = compile(schema), decode = (value) => value.indexOf(",") !== -1 ? compiler.Decode(value.split(",")) : compiler.Decode([value]);
|
|
235
235
|
return t.Transform(
|
|
236
236
|
t.Union(
|
|
237
237
|
[
|
package/dist/utils.js
CHANGED
|
@@ -62,8 +62,8 @@ __export(utils_exports, {
|
|
|
62
62
|
module.exports = __toCommonJS(utils_exports);
|
|
63
63
|
var import_file = require('./universal/file.js');
|
|
64
64
|
const hasHeaderShorthand = "toJSON" in new Headers(), replaceUrlPath = (url, pathname) => {
|
|
65
|
-
const
|
|
66
|
-
return
|
|
65
|
+
const pathStartIndex = url.indexOf("/", 11), queryIndex = url.indexOf("?", pathStartIndex);
|
|
66
|
+
return queryIndex === -1 ? `${url.slice(0, pathStartIndex)}${pathname.charCodeAt(0) === 47 ? "" : "/"}${pathname}` : `${url.slice(0, pathStartIndex)}${pathname.charCodeAt(0) === 47 ? "" : "/"}${pathname}${url.slice(queryIndex)}`;
|
|
67
67
|
}, isClass = (v) => typeof v == "function" && /^\s*class\s+/.test(v.toString()) || // Handle Object.create(null)
|
|
68
68
|
v.toString && // Handle import * as Sentry from '@sentry/bun'
|
|
69
69
|
// This also handle [object Date], [object Array]
|
package/dist/utils.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ElysiaFile } from "./universal/file.mjs";
|
|
2
2
|
const hasHeaderShorthand = "toJSON" in new Headers(), replaceUrlPath = (url, pathname) => {
|
|
3
|
-
const
|
|
4
|
-
return
|
|
3
|
+
const pathStartIndex = url.indexOf("/", 11), queryIndex = url.indexOf("?", pathStartIndex);
|
|
4
|
+
return queryIndex === -1 ? `${url.slice(0, pathStartIndex)}${pathname.charCodeAt(0) === 47 ? "" : "/"}${pathname}` : `${url.slice(0, pathStartIndex)}${pathname.charCodeAt(0) === 47 ? "" : "/"}${pathname}${url.slice(queryIndex)}`;
|
|
5
5
|
}, isClass = (v) => typeof v == "function" && /^\s*class\s+/.test(v.toString()) || // Handle Object.create(null)
|
|
6
6
|
v.toString && // Handle import * as Sentry from '@sentry/bun'
|
|
7
7
|
// This also handle [object Date], [object Array]
|