elysia 2.0.0-exp.11 → 2.0.0-exp.13
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/_virtual/_rolldown/runtime.js +2 -0
- package/dist/adapter/bun/index.d.ts +1 -1
- package/dist/adapter/bun/index.js +2 -0
- package/dist/adapter/bun/index.mjs +2 -0
- package/dist/adapter/constants.d.ts +1 -1
- package/dist/adapter/index.d.ts +1 -1
- package/dist/adapter/utils.d.ts +4 -1
- package/dist/adapter/utils.js +3 -4
- package/dist/adapter/utils.mjs +1 -2
- package/dist/adapter/web-standard/index.d.ts +1 -1
- package/dist/base.d.ts +35 -5
- package/dist/base.js +58 -7
- package/dist/base.mjs +58 -7
- package/dist/compile/handler/index.js +1 -1
- package/dist/compile/handler/index.mjs +1 -1
- package/dist/compile/handler/jit.js +2 -2
- package/dist/compile/handler/jit.mjs +2 -2
- package/dist/compile/handler/params.js +1 -1
- package/dist/compile/handler/params.mjs +1 -1
- package/dist/compile/handler/reconstruct.js +1 -1
- package/dist/compile/handler/reconstruct.mjs +1 -1
- package/dist/cookie/index.d.ts +2 -2
- package/dist/handler/fetch.js +19 -24
- package/dist/handler/fetch.mjs +19 -24
- package/dist/index.d.ts +3 -5
- package/dist/index.js +0 -4
- package/dist/index.mjs +1 -3
- package/dist/type/elysia/file-type.d.ts +1 -1
- package/dist/type/exports.js +29 -2059
- package/dist/type/exports.mjs +7 -295
- package/dist/type/index.d.ts +3 -1
- package/dist/type/validator/index.d.ts +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/universal/file.d.ts +8 -8
- package/dist/universal/file.js +8 -8
- package/dist/universal/file.mjs +8 -8
- package/dist/utils.d.ts +1 -1
- package/dist/validator/index.d.ts +1 -1
- package/dist/validator/index.js +2 -2
- package/dist/validator/index.mjs +2 -2
- package/dist/ws/route.js +5 -1
- package/dist/ws/route.mjs +6 -2
- package/package.json +8 -3
package/dist/handler/fetch.mjs
CHANGED
|
@@ -2,10 +2,10 @@ import { flattenChain, isNotEmpty, nullObject, requestId } from "../utils.mjs";
|
|
|
2
2
|
import { handleSet } from "../adapter/utils.mjs";
|
|
3
3
|
import { NotFound } from "../error.mjs";
|
|
4
4
|
import { createContext } from "../context.mjs";
|
|
5
|
-
import { defaultAdapter } from "../adapter/constants.mjs";
|
|
6
5
|
import { cachedResponse, getAsyncIndexes } from "./utils.mjs";
|
|
7
|
-
import { createErrorHandler } from "./error.mjs";
|
|
8
6
|
import { createTracer } from "../trace.mjs";
|
|
7
|
+
import { defaultAdapter } from "../adapter/constants.mjs";
|
|
8
|
+
import { createErrorHandler } from "./error.mjs";
|
|
9
9
|
import { decodeComponent } from "deuri";
|
|
10
10
|
|
|
11
11
|
//#region src/handler/fetch.ts
|
|
@@ -28,11 +28,17 @@ const decodeParams = (params) => {
|
|
|
28
28
|
}
|
|
29
29
|
return params;
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
function finalizeError(context, handleError, afterResponse, error) {
|
|
32
32
|
const resp = handleError(context, error);
|
|
33
|
-
afterResponse
|
|
33
|
+
if (!afterResponse) return resp;
|
|
34
|
+
if (resp instanceof Promise) return resp.then((r) => {
|
|
35
|
+
afterResponse(context);
|
|
36
|
+
return r;
|
|
37
|
+
});
|
|
38
|
+
afterResponse(context);
|
|
34
39
|
return resp;
|
|
35
|
-
}
|
|
40
|
+
}
|
|
41
|
+
const catchError = (context, handleError, afterResponse) => (error) => finalizeError(context, handleError, afterResponse, error);
|
|
36
42
|
function findRoute(context, request, map, router, hasError, handleError, afterResponse, strictPath, hasWS) {
|
|
37
43
|
const path = context.path;
|
|
38
44
|
if (hasWS) {
|
|
@@ -50,7 +56,8 @@ function findRoute(context, request, map, router, hasError, handleError, afterRe
|
|
|
50
56
|
return r instanceof Promise ? r.catch(catchError(context, handleError, afterResponse)) : r;
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
|
-
}
|
|
59
|
+
}
|
|
60
|
+
{
|
|
54
61
|
const methodMap = map[request.method];
|
|
55
62
|
let handler = methodMap?.[path];
|
|
56
63
|
if (!handler) if (!strictPath && path.length > 1 && path.charCodeAt(path.length - 1) === 47) {
|
|
@@ -173,9 +180,7 @@ function createFetchHandler(app) {
|
|
|
173
180
|
return await findRoute(context, request, map, router, hasError, handleError, afterResponse, strictPath, hasWS);
|
|
174
181
|
} catch (error) {
|
|
175
182
|
for (let i = 0; i < traceLength; i++) requestReports[i].resolve(error);
|
|
176
|
-
|
|
177
|
-
afterResponse?.(context);
|
|
178
|
-
return r;
|
|
183
|
+
return finalizeError(context, handleError, afterResponse, error);
|
|
179
184
|
}
|
|
180
185
|
};
|
|
181
186
|
}
|
|
@@ -197,9 +202,7 @@ function createFetchHandler(app) {
|
|
|
197
202
|
}
|
|
198
203
|
return findRoute(context, request, map, router, hasError, handleError, afterResponse, strictPath, hasWS);
|
|
199
204
|
} catch (error) {
|
|
200
|
-
|
|
201
|
-
afterResponse?.(context);
|
|
202
|
-
return r;
|
|
205
|
+
return finalizeError(context, handleError, afterResponse, error);
|
|
203
206
|
}
|
|
204
207
|
};
|
|
205
208
|
return (request) => {
|
|
@@ -217,7 +220,7 @@ function createFetchHandler(app) {
|
|
|
217
220
|
}
|
|
218
221
|
return findRoute(context, request, map, router, hasError, handleError, afterResponse, strictPath, hasWS);
|
|
219
222
|
} catch (error) {
|
|
220
|
-
return
|
|
223
|
+
return finalizeError(context, handleError, afterResponse, error);
|
|
221
224
|
}
|
|
222
225
|
};
|
|
223
226
|
}
|
|
@@ -241,9 +244,7 @@ function createFetchHandler(app) {
|
|
|
241
244
|
return r instanceof Promise ? r.catch(catchError(context, handleError, afterResponse)) : r;
|
|
242
245
|
}
|
|
243
246
|
} catch (error) {
|
|
244
|
-
|
|
245
|
-
afterResponse?.(context);
|
|
246
|
-
return r;
|
|
247
|
+
return finalizeError(context, handleError, afterResponse, error);
|
|
247
248
|
}
|
|
248
249
|
}
|
|
249
250
|
}
|
|
@@ -269,15 +270,9 @@ function createFetchHandler(app) {
|
|
|
269
270
|
return r instanceof Promise ? r.catch(catchError(context, handleError, afterResponse)) : r;
|
|
270
271
|
}
|
|
271
272
|
} catch (error) {
|
|
272
|
-
|
|
273
|
-
afterResponse?.(context);
|
|
274
|
-
return r;
|
|
275
|
-
}
|
|
276
|
-
if (hasError) {
|
|
277
|
-
const r = handleError(context, new NotFound());
|
|
278
|
-
afterResponse?.(context);
|
|
279
|
-
return r;
|
|
273
|
+
return finalizeError(context, handleError, afterResponse, error);
|
|
280
274
|
}
|
|
275
|
+
if (hasError) return finalizeError(context, handleError, afterResponse, new NotFound());
|
|
281
276
|
afterResponse?.(context, 404);
|
|
282
277
|
return notFound(context);
|
|
283
278
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { StatusMap, StatusMapBack } from "./constants.js";
|
|
2
2
|
import { ElysiaError, ElysiaStatus, InternalServerError, InvalidCookieSignature, NotFound, ParseError, ValidationError, status, validationDetail } from "./error.js";
|
|
3
|
-
import { Cookie } from "./cookie/cookie.js";
|
|
4
|
-
import { serializeCookie } from "./cookie/serialize.js";
|
|
5
3
|
import { ElysiaFile, file } from "./universal/file.js";
|
|
6
4
|
import { TraceEvent, TraceHandler, TraceListener, TraceProcess, TraceStream } from "./trace.js";
|
|
7
|
-
import { env } from "./universal/env.js";
|
|
8
|
-
import { SSEPayload } from "./types.js";
|
|
9
5
|
import { AnySchema, BaseSchema, StandardJSONSchemaV1Like, StandardSchemaV1Like } from "./type/types.js";
|
|
10
6
|
import { FileTypeDetector, fileType, setFileTypeDetector } from "./type/elysia/file-type.js";
|
|
11
7
|
import { setupTypebox } from "./type/compat.js";
|
|
@@ -13,7 +9,9 @@ import { Capture, Compiled } from "./compile/aot.js";
|
|
|
13
9
|
import { MultiValidator, StandardValidator, Validator } from "./validator/index.js";
|
|
14
10
|
import { TypeBoxValidator } from "./type/validator/index.js";
|
|
15
11
|
import { TypeSystem, t } from "./type/index.js";
|
|
12
|
+
import { env } from "./universal/env.js";
|
|
13
|
+
import { SSEPayload } from "./types.js";
|
|
16
14
|
import { form, redirect, sse } from "./utils.js";
|
|
17
15
|
import { Context, ErrorContext, createBaseContext, createContext } from "./context.js";
|
|
18
16
|
import { Elysia } from "./base.js";
|
|
19
|
-
export { type AnySchema, type BaseSchema, Compiled, type Context,
|
|
17
|
+
export { type AnySchema, type BaseSchema, Compiled, type Context, Elysia, Elysia as default, ElysiaError, ElysiaFile, ElysiaStatus, type ErrorContext, type FileTypeDetector, InternalServerError, InvalidCookieSignature, Capture as Manifest, MultiValidator, NotFound, ParseError, type SSEPayload, type StandardJSONSchemaV1Like, type StandardSchemaV1Like, StandardValidator, StatusMap, StatusMapBack, type TraceEvent, type TraceHandler, type TraceListener, type TraceProcess, type TraceStream, TypeBoxValidator, TypeSystem, ValidationError, Validator, createBaseContext, createContext, env, file, fileType, form, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
|
package/dist/index.js
CHANGED
|
@@ -3,13 +3,11 @@ const require_runtime = require('./_virtual/_rolldown/runtime.js');
|
|
|
3
3
|
const require_constants = require('./constants.js');
|
|
4
4
|
const require_universal_file = require('./universal/file.js');
|
|
5
5
|
const require_utils = require('./utils.js');
|
|
6
|
-
const require_cookie_serialize = require('./cookie/serialize.js');
|
|
7
6
|
const require_universal_env = require('./universal/env.js');
|
|
8
7
|
const require_error = require('./error.js');
|
|
9
8
|
const require_context = require('./context.js');
|
|
10
9
|
const require_compile_aot = require('./compile/aot.js');
|
|
11
10
|
const require_validator_index = require('./validator/index.js');
|
|
12
|
-
const require_cookie_cookie = require('./cookie/cookie.js');
|
|
13
11
|
const require_base = require('./base.js');
|
|
14
12
|
const require_type_elysia_file_type = require('./type/elysia/file-type.js');
|
|
15
13
|
const require_type_validator_index = require('./type/validator/index.js');
|
|
@@ -22,7 +20,6 @@ var src_default = require_base.Elysia;
|
|
|
22
20
|
|
|
23
21
|
//#endregion
|
|
24
22
|
exports.Compiled = require_compile_aot.Compiled;
|
|
25
|
-
exports.Cookie = require_cookie_cookie.Cookie;
|
|
26
23
|
exports.Elysia = require_base.Elysia;
|
|
27
24
|
exports.ElysiaError = require_error.ElysiaError;
|
|
28
25
|
exports.ElysiaFile = require_universal_file.ElysiaFile;
|
|
@@ -53,7 +50,6 @@ exports.file = require_universal_file.file;
|
|
|
53
50
|
exports.fileType = require_type_elysia_file_type.fileType;
|
|
54
51
|
exports.form = require_utils.form;
|
|
55
52
|
exports.redirect = require_utils.redirect;
|
|
56
|
-
exports.serializeCookie = require_cookie_serialize.serializeCookie;
|
|
57
53
|
exports.setFileTypeDetector = require_type_elysia_file_type.setFileTypeDetector;
|
|
58
54
|
exports.setupTypebox = require_type_compat.setupTypebox;
|
|
59
55
|
exports.sse = require_utils.sse;
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { StatusMap, StatusMapBack } from "./constants.mjs";
|
|
2
2
|
import { ElysiaFile, file } from "./universal/file.mjs";
|
|
3
3
|
import { form, redirect, sse } from "./utils.mjs";
|
|
4
|
-
import { serializeCookie } from "./cookie/serialize.mjs";
|
|
5
4
|
import { env } from "./universal/env.mjs";
|
|
6
5
|
import { ElysiaError, ElysiaStatus, InternalServerError, InvalidCookieSignature, NotFound, ParseError, ValidationError, status, validationDetail } from "./error.mjs";
|
|
7
6
|
import { createBaseContext, createContext } from "./context.mjs";
|
|
8
7
|
import { Capture, Compiled } from "./compile/aot.mjs";
|
|
9
8
|
import { MultiValidator, StandardValidator, Validator } from "./validator/index.mjs";
|
|
10
|
-
import { Cookie } from "./cookie/cookie.mjs";
|
|
11
9
|
import { Elysia } from "./base.mjs";
|
|
12
10
|
import { fileType, setFileTypeDetector } from "./type/elysia/file-type.mjs";
|
|
13
11
|
import { TypeBoxValidator } from "./type/validator/index.mjs";
|
|
@@ -18,4 +16,4 @@ import { TypeSystem, t } from "./type/index.mjs";
|
|
|
18
16
|
var src_default = Elysia;
|
|
19
17
|
|
|
20
18
|
//#endregion
|
|
21
|
-
export { Compiled,
|
|
19
|
+
export { Compiled, Elysia, ElysiaError, ElysiaFile, ElysiaStatus, InternalServerError, InvalidCookieSignature, Capture as Manifest, MultiValidator, NotFound, ParseError, StandardValidator, StatusMap, StatusMapBack, TypeBoxValidator, TypeSystem, ValidationError, Validator, createBaseContext, createContext, src_default as default, env, file, fileType, form, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
|
|
@@ -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 | {
|