elysia 1.4.29 → 2.0.0-beta.0
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 +29 -0
- package/dist/_virtual/_rolldown/runtime.mjs +38 -0
- package/dist/adapter/bun/index.d.ts +7 -6
- package/dist/adapter/bun/index.js +219 -380
- package/dist/adapter/bun/index.mjs +217 -382
- package/dist/adapter/constants.d.ts +6 -0
- package/dist/adapter/constants.js +10 -0
- package/dist/adapter/constants.mjs +9 -0
- package/dist/adapter/default-headers.d.ts +4 -0
- package/dist/adapter/default-headers.js +7 -0
- package/dist/adapter/default-headers.mjs +5 -0
- package/dist/adapter/index.d.ts +8 -1
- package/dist/adapter/index.js +7 -14
- package/dist/adapter/index.mjs +5 -0
- package/dist/adapter/origin.d.ts +63 -0
- package/dist/adapter/origin.js +64 -0
- package/dist/adapter/origin.mjs +62 -0
- package/dist/adapter/response-ownership.d.ts +5 -0
- package/dist/adapter/response-ownership.js +13 -0
- package/dist/adapter/response-ownership.mjs +10 -0
- package/dist/adapter/skip-clone.d.ts +4 -0
- package/dist/adapter/skip-clone.js +7 -0
- package/dist/adapter/skip-clone.mjs +5 -0
- package/dist/adapter/types.d.ts +50 -125
- package/dist/adapter/types.js +1 -14
- package/dist/adapter/types.mjs +1 -0
- package/dist/adapter/utils.d.ts +47 -19
- package/dist/adapter/utils.js +561 -311
- package/dist/adapter/utils.mjs +551 -283
- package/dist/adapter/web-standard/handler.d.ts +11 -9
- package/dist/adapter/web-standard/handler.js +146 -415
- package/dist/adapter/web-standard/handler.mjs +144 -400
- package/dist/adapter/web-standard/index.d.ts +5 -2
- package/dist/adapter/web-standard/index.js +68 -162
- package/dist/adapter/web-standard/index.mjs +68 -147
- package/dist/adapter/web-standard/utils.d.ts +4 -0
- package/dist/adapter/web-standard/utils.js +153 -0
- package/dist/adapter/web-standard/utils.mjs +152 -0
- package/dist/base.d.ts +898 -0
- package/dist/base.js +1564 -0
- package/dist/base.mjs +1561 -0
- package/dist/compile/analysis-cache.d.ts +6 -0
- package/dist/compile/analysis-cache.js +12 -0
- package/dist/compile/analysis-cache.mjs +11 -0
- package/dist/compile/aot-capture.d.ts +24 -0
- package/dist/compile/aot-capture.js +376 -0
- package/dist/compile/aot-capture.mjs +365 -0
- package/dist/compile/aot-emit.d.ts +29 -0
- package/dist/compile/aot-emit.js +107 -0
- package/dist/compile/aot-emit.mjs +101 -0
- package/dist/compile/aot-reconstruct.d.ts +30 -0
- package/dist/compile/aot-reconstruct.js +156 -0
- package/dist/compile/aot-reconstruct.mjs +147 -0
- package/dist/compile/aot.d.ts +287 -0
- package/dist/compile/aot.js +220 -0
- package/dist/compile/aot.mjs +200 -0
- package/dist/compile/handler/descriptor.d.ts +77 -0
- package/dist/compile/handler/descriptor.js +199 -0
- package/dist/compile/handler/descriptor.mjs +194 -0
- package/dist/compile/handler/frozen-validator.d.ts +39 -0
- package/dist/compile/handler/frozen-validator.js +319 -0
- package/dist/compile/handler/frozen-validator.mjs +313 -0
- package/dist/compile/handler/index.d.ts +19 -0
- package/dist/compile/handler/index.js +379 -0
- package/dist/compile/handler/index.mjs +371 -0
- package/dist/compile/handler/jit.d.ts +43 -0
- package/dist/compile/handler/jit.js +536 -0
- package/dist/compile/handler/jit.mjs +532 -0
- package/dist/compile/handler/params.d.ts +28 -0
- package/dist/compile/handler/params.js +78 -0
- package/dist/compile/handler/params.mjs +76 -0
- package/dist/compile/handler/reconstruct.d.ts +12 -0
- package/dist/compile/handler/reconstruct.js +50 -0
- package/dist/compile/handler/reconstruct.mjs +49 -0
- package/dist/compile/handler/utils.d.ts +45 -0
- package/dist/compile/handler/utils.js +514 -0
- package/dist/compile/handler/utils.mjs +498 -0
- package/dist/compile/jit-probe.d.ts +15 -0
- package/dist/compile/jit-probe.js +28 -0
- package/dist/compile/jit-probe.mjs +26 -0
- package/dist/compile/lexer.d.ts +7 -0
- package/dist/compile/lexer.js +53 -0
- package/dist/compile/lexer.mjs +48 -0
- package/dist/compile/utils.d.ts +8 -0
- package/dist/compile/utils.js +23 -0
- package/dist/compile/utils.mjs +19 -0
- package/dist/compiled.d.ts +17 -0
- package/dist/compiled.js +20 -0
- package/dist/compiled.mjs +16 -0
- package/dist/constants.d.ts +137 -0
- package/dist/constants.js +96 -0
- package/dist/constants.mjs +88 -0
- package/dist/context.d.ts +86 -129
- package/dist/context.js +110 -13
- package/dist/context.mjs +108 -0
- package/dist/cookie/config.d.ts +31 -0
- package/dist/cookie/config.js +98 -0
- package/dist/cookie/config.mjs +95 -0
- package/dist/cookie/cookie.d.ts +26 -0
- package/dist/cookie/cookie.js +105 -0
- package/dist/cookie/cookie.mjs +104 -0
- package/dist/cookie/crypto.d.ts +20 -0
- package/dist/cookie/crypto.js +168 -0
- package/dist/cookie/crypto.mjs +151 -0
- package/dist/cookie/error.d.ts +17 -0
- package/dist/cookie/error.js +25 -0
- package/dist/cookie/error.mjs +24 -0
- package/dist/cookie/index.d.ts +7 -0
- package/dist/cookie/index.js +13 -0
- package/dist/cookie/index.mjs +7 -0
- package/dist/cookie/lib.d.ts +7 -0
- package/dist/cookie/lib.js +76 -0
- package/dist/cookie/lib.mjs +74 -0
- package/dist/cookie/serialize.d.ts +6 -0
- package/dist/cookie/serialize.js +32 -0
- package/dist/cookie/serialize.mjs +31 -0
- package/dist/cookie/types.d.ts +113 -0
- package/dist/cookie/types.js +1 -0
- package/dist/cookie/types.mjs +1 -0
- package/dist/cookie/utils.d.ts +25 -0
- package/dist/cookie/utils.js +182 -0
- package/dist/cookie/utils.mjs +171 -0
- package/dist/error.d.ts +226 -188
- package/dist/error.js +519 -357
- package/dist/error.mjs +503 -327
- package/dist/generation.d.ts +30 -0
- package/dist/generation.js +23 -0
- package/dist/generation.mjs +17 -0
- package/dist/handler/error.d.ts +7 -0
- package/dist/handler/error.js +105 -0
- package/dist/handler/error.mjs +104 -0
- package/dist/handler/fetch.d.ts +8 -0
- package/dist/handler/fetch.js +371 -0
- package/dist/handler/fetch.mjs +367 -0
- package/dist/handler/index.d.ts +2 -0
- package/dist/handler/index.js +5 -0
- package/dist/handler/index.mjs +3 -0
- package/dist/handler/utils.d.ts +15 -0
- package/dist/handler/utils.js +48 -0
- package/dist/handler/utils.mjs +42 -0
- package/dist/index.d.ts +23 -2198
- package/dist/index.js +62 -1948
- package/dist/index.mjs +20 -1986
- package/dist/memory.d.ts +4 -0
- package/dist/memory.js +17 -0
- package/dist/memory.mjs +16 -0
- package/dist/package.js +11 -0
- package/dist/package.mjs +5 -0
- package/dist/parse-query.d.ts +7 -9
- package/dist/parse-query.js +154 -164
- package/dist/parse-query.mjs +150 -133
- package/dist/plugin/aot/bun.d.ts +26 -0
- package/dist/plugin/aot/bun.js +35 -0
- package/dist/plugin/aot/bun.mjs +34 -0
- package/dist/plugin/aot/core.d.ts +291 -0
- package/dist/plugin/aot/core.js +505 -0
- package/dist/plugin/aot/core.mjs +481 -0
- package/dist/plugin/aot/esbuild.d.ts +28 -0
- package/dist/plugin/aot/esbuild.js +48 -0
- package/dist/plugin/aot/esbuild.mjs +46 -0
- package/dist/plugin/aot/hooks.d.ts +28 -0
- package/dist/plugin/aot/hooks.js +114 -0
- package/dist/plugin/aot/hooks.mjs +112 -0
- package/dist/plugin/aot/rspack-loader.d.ts +23 -0
- package/dist/plugin/aot/rspack-loader.js +44 -0
- package/dist/plugin/aot/rspack-loader.mjs +40 -0
- package/dist/plugin/aot/rspack.d.ts +23 -0
- package/dist/plugin/aot/rspack.js +85 -0
- package/dist/plugin/aot/rspack.mjs +82 -0
- package/dist/plugin/aot/source.d.ts +60 -0
- package/dist/plugin/aot/source.js +422 -0
- package/dist/plugin/aot/source.mjs +418 -0
- package/dist/plugin/aot/treeshake.d.ts +4 -0
- package/dist/plugin/aot/treeshake.js +95 -0
- package/dist/plugin/aot/treeshake.mjs +94 -0
- package/dist/plugin/aot/unplugin.d.ts +50 -0
- package/dist/plugin/aot/unplugin.js +64 -0
- package/dist/plugin/aot/unplugin.mjs +62 -0
- package/dist/plugin/aot/vite.d.ts +30 -0
- package/dist/plugin/aot/vite.js +34 -0
- package/dist/plugin/aot/vite.mjs +33 -0
- package/dist/plugin/aot/worker.d.ts +1 -0
- package/dist/plugin/aot/worker.js +28 -0
- package/dist/plugin/aot/worker.mjs +27 -0
- package/dist/plugin/auto-head.d.ts +6 -0
- package/dist/plugin/auto-head.js +38 -0
- package/dist/plugin/auto-head.mjs +36 -0
- package/dist/plugin/trace.d.ts +10 -0
- package/dist/plugin/trace.js +39 -0
- package/dist/plugin/trace.mjs +36 -0
- package/dist/plugin/websocket.d.ts +6 -0
- package/dist/plugin/websocket.js +61 -0
- package/dist/plugin/websocket.mjs +60 -0
- package/dist/route-table.d.ts +28 -0
- package/dist/route-table.js +64 -0
- package/dist/route-table.mjs +61 -0
- package/dist/schema-snapshot.d.ts +9 -0
- package/dist/schema-snapshot.js +271 -0
- package/dist/schema-snapshot.mjs +269 -0
- package/dist/sucrose.d.ts +28 -63
- package/dist/sucrose.js +814 -306
- package/dist/sucrose.mjs +805 -274
- package/dist/trace.d.ts +145 -130
- package/dist/trace.js +387 -135
- package/dist/trace.mjs +385 -113
- package/dist/type/bridge-live.d.ts +15 -0
- package/dist/type/bridge-live.js +39 -0
- package/dist/type/bridge-live.mjs +17 -0
- package/dist/type/bridge.d.ts +56 -0
- package/dist/type/bridge.js +180 -0
- package/dist/type/bridge.mjs +63 -0
- package/dist/type/coerce-plan.d.ts +38 -0
- package/dist/type/coerce-plan.js +107 -0
- package/dist/type/coerce-plan.mjs +98 -0
- package/dist/type/coerce.d.ts +43 -0
- package/dist/type/coerce.js +351 -0
- package/dist/type/coerce.mjs +339 -0
- package/dist/type/compat.d.ts +8 -0
- package/dist/type/compat.js +46 -0
- package/dist/type/compat.mjs +44 -0
- package/dist/type/constants.d.ts +25 -0
- package/dist/type/constants.js +36 -0
- package/dist/type/constants.mjs +32 -0
- package/dist/type/elysia/accelerate.d.ts +6 -0
- package/dist/type/elysia/accelerate.js +12 -0
- package/dist/type/elysia/accelerate.mjs +10 -0
- package/dist/type/elysia/array-buffer.d.ts +6 -0
- package/dist/type/elysia/array-buffer.js +27 -0
- package/dist/type/elysia/array-buffer.mjs +25 -0
- package/dist/type/elysia/array-string.d.ts +7 -0
- package/dist/type/elysia/array-string.js +28 -0
- package/dist/type/elysia/array-string.mjs +26 -0
- package/dist/type/elysia/array.d.ts +6 -0
- package/dist/type/elysia/array.js +32 -0
- package/dist/type/elysia/array.mjs +31 -0
- package/dist/type/elysia/boolean-string.d.ts +6 -0
- package/dist/type/elysia/boolean-string.js +24 -0
- package/dist/type/elysia/boolean-string.mjs +22 -0
- package/dist/type/elysia/boolean.d.ts +6 -0
- package/dist/type/elysia/boolean.js +20 -0
- package/dist/type/elysia/boolean.mjs +18 -0
- package/dist/type/elysia/cookie.d.ts +15 -0
- package/dist/type/elysia/cookie.js +51 -0
- package/dist/type/elysia/cookie.mjs +50 -0
- package/dist/type/elysia/date.d.ts +7 -0
- package/dist/type/elysia/date.js +98 -0
- package/dist/type/elysia/date.mjs +96 -0
- package/dist/type/elysia/file-type.d.ts +25 -0
- package/dist/type/elysia/file-type.js +81 -0
- package/dist/type/elysia/file-type.mjs +71 -0
- package/dist/type/elysia/file.d.ts +9 -0
- package/dist/type/elysia/file.js +64 -0
- package/dist/type/elysia/file.mjs +48 -0
- package/dist/type/elysia/files.d.ts +8 -0
- package/dist/type/elysia/files.js +45 -0
- package/dist/type/elysia/files.mjs +43 -0
- package/dist/type/elysia/form.d.ts +8 -0
- package/dist/type/elysia/form.js +17 -0
- package/dist/type/elysia/form.mjs +15 -0
- package/dist/type/elysia/integer-string.d.ts +7 -0
- package/dist/type/elysia/integer-string.js +40 -0
- package/dist/type/elysia/integer-string.mjs +38 -0
- package/dist/type/elysia/integer.d.ts +6 -0
- package/dist/type/elysia/integer.js +20 -0
- package/dist/type/elysia/integer.mjs +18 -0
- package/dist/type/elysia/intersect.d.ts +6 -0
- package/dist/type/elysia/intersect.js +20 -0
- package/dist/type/elysia/intersect.mjs +19 -0
- package/dist/type/elysia/maybe-empty.d.ts +7 -0
- package/dist/type/elysia/maybe-empty.js +21 -0
- package/dist/type/elysia/maybe-empty.mjs +19 -0
- package/dist/type/elysia/no-validate.d.ts +6 -0
- package/dist/type/elysia/no-validate.js +9 -0
- package/dist/type/elysia/no-validate.mjs +8 -0
- package/dist/type/elysia/nullable.d.ts +7 -0
- package/dist/type/elysia/nullable.js +15 -0
- package/dist/type/elysia/nullable.mjs +13 -0
- package/dist/type/elysia/number.d.ts +6 -0
- package/dist/type/elysia/number.js +20 -0
- package/dist/type/elysia/number.mjs +18 -0
- package/dist/type/elysia/numeric-enum.d.ts +11 -0
- package/dist/type/elysia/numeric-enum.js +26 -0
- package/dist/type/elysia/numeric-enum.mjs +24 -0
- package/dist/type/elysia/numeric.d.ts +7 -0
- package/dist/type/elysia/numeric.js +62 -0
- package/dist/type/elysia/numeric.mjs +60 -0
- package/dist/type/elysia/object-string.d.ts +7 -0
- package/dist/type/elysia/object-string.js +28 -0
- package/dist/type/elysia/object-string.mjs +26 -0
- package/dist/type/elysia/object.d.ts +6 -0
- package/dist/type/elysia/object.js +47 -0
- package/dist/type/elysia/object.mjs +46 -0
- package/dist/type/elysia/optional.d.ts +6 -0
- package/dist/type/elysia/optional.js +22 -0
- package/dist/type/elysia/optional.mjs +21 -0
- package/dist/type/elysia/string.d.ts +6 -0
- package/dist/type/elysia/string.js +43 -0
- package/dist/type/elysia/string.mjs +41 -0
- package/dist/type/elysia/uint8-array.d.ts +6 -0
- package/dist/type/elysia/uint8-array.js +27 -0
- package/dist/type/elysia/uint8-array.mjs +25 -0
- package/dist/type/elysia/union-enum.d.ts +8 -0
- package/dist/type/elysia/union-enum.js +31 -0
- package/dist/type/elysia/union-enum.mjs +29 -0
- package/dist/type/elysia/union.d.ts +6 -0
- package/dist/type/elysia/union.js +20 -0
- package/dist/type/elysia/union.mjs +19 -0
- package/dist/type/elysia/utils.d.ts +53 -0
- package/dist/type/elysia/utils.js +98 -0
- package/dist/type/elysia/utils.mjs +88 -0
- package/dist/type/exports.d.ts +36 -0
- package/dist/type/exports.js +68 -0
- package/dist/type/exports.mjs +36 -0
- package/dist/type/index.d.ts +13 -0
- package/dist/type/index.js +81 -0
- package/dist/type/index.mjs +68 -0
- package/dist/type/shared.d.ts +27 -0
- package/dist/type/shared.js +171 -0
- package/dist/type/shared.mjs +161 -0
- package/dist/type/types.d.ts +206 -0
- package/dist/type/types.js +1 -0
- package/dist/type/types.mjs +1 -0
- package/dist/type/utils.d.ts +7 -0
- package/dist/type/utils.js +43 -0
- package/dist/type/utils.mjs +41 -0
- package/dist/type/validator/clean-safe.d.ts +8 -0
- package/dist/type/validator/clean-safe.js +82 -0
- package/dist/type/validator/clean-safe.mjs +77 -0
- package/dist/type/validator/custom-error.d.ts +10 -0
- package/dist/type/validator/custom-error.js +191 -0
- package/dist/type/validator/custom-error.mjs +188 -0
- package/dist/type/validator/default-precompute.d.ts +26 -0
- package/dist/type/validator/default-precompute.js +432 -0
- package/dist/type/validator/default-precompute.mjs +421 -0
- package/dist/type/validator/exact-mirror.d.ts +7 -0
- package/dist/type/validator/exact-mirror.js +19 -0
- package/dist/type/validator/exact-mirror.mjs +15 -0
- package/dist/type/validator/frozen-check.d.ts +11 -0
- package/dist/type/validator/frozen-check.js +20 -0
- package/dist/type/validator/frozen-check.mjs +19 -0
- package/dist/type/validator/index.d.ts +32 -0
- package/dist/type/validator/index.js +657 -0
- package/dist/type/validator/index.mjs +651 -0
- package/dist/type/validator/string-codec-aot.d.ts +8 -0
- package/dist/type/validator/string-codec-aot.js +68 -0
- package/dist/type/validator/string-codec-aot.mjs +66 -0
- package/dist/type/validator/validator-cache.d.ts +26 -0
- package/dist/type/validator/validator-cache.js +247 -0
- package/dist/type/validator/validator-cache.mjs +242 -0
- package/dist/types.d.ts +938 -1235
- package/dist/types.js +1 -14
- package/dist/types.mjs +1 -0
- package/dist/universal/constants.d.ts +6 -0
- package/dist/universal/constants.js +19 -0
- package/dist/universal/constants.mjs +15 -0
- package/dist/universal/env.d.ts +5 -1
- package/dist/universal/env.js +12 -26
- package/dist/universal/env.mjs +10 -5
- package/dist/universal/file.d.ts +55 -86
- package/dist/universal/file.js +116 -157
- package/dist/universal/file.mjs +111 -132
- package/dist/universal/index.d.ts +5 -3
- package/dist/universal/index.js +8 -27
- package/dist/universal/index.mjs +4 -5
- package/dist/universal/is-production.d.ts +5 -0
- package/dist/universal/is-production.js +10 -0
- package/dist/universal/is-production.mjs +8 -0
- package/dist/universal/server.d.ts +318 -313
- package/dist/universal/server.js +1 -14
- package/dist/universal/server.mjs +1 -0
- package/dist/utils.d.ts +162 -191
- package/dist/utils.js +732 -693
- package/dist/utils.mjs +683 -631
- package/dist/validator/index.d.ts +63 -0
- package/dist/validator/index.js +299 -0
- package/dist/validator/index.mjs +296 -0
- package/dist/validator/route.d.ts +32 -0
- package/dist/validator/route.js +51 -0
- package/dist/validator/route.mjs +50 -0
- package/dist/ws/context.d.ts +49 -0
- package/dist/ws/context.js +152 -0
- package/dist/ws/context.mjs +150 -0
- package/dist/ws/index.d.ts +5 -77
- package/dist/ws/index.js +11 -180
- package/dist/ws/index.mjs +5 -157
- package/dist/ws/parser.d.ts +5 -0
- package/dist/ws/parser.js +69 -0
- package/dist/ws/parser.mjs +66 -0
- package/dist/ws/route.d.ts +16 -0
- package/dist/ws/route.js +560 -0
- package/dist/ws/route.mjs +554 -0
- package/dist/ws/types.d.ts +154 -57
- package/dist/ws/types.js +1 -14
- package/dist/ws/types.mjs +1 -0
- package/package.json +179 -120
- package/bunfig.toml +0 -2
- package/dist/adapter/bun/compose.d.ts +0 -3
- package/dist/adapter/bun/compose.js +0 -90
- package/dist/adapter/bun/compose.mjs +0 -74
- package/dist/adapter/bun/handler-native.d.ts +0 -3
- package/dist/adapter/bun/handler-native.js +0 -42
- package/dist/adapter/bun/handler-native.mjs +0 -22
- package/dist/adapter/bun/handler.d.ts +0 -7
- package/dist/adapter/bun/handler.js +0 -363
- package/dist/adapter/bun/handler.mjs +0 -346
- package/dist/adapter/cloudflare-worker/index.d.ts +0 -20
- package/dist/adapter/cloudflare-worker/index.js +0 -59
- package/dist/adapter/cloudflare-worker/index.mjs +0 -39
- package/dist/compose.d.ts +0 -30
- package/dist/compose.js +0 -1324
- package/dist/compose.mjs +0 -1336
- package/dist/cookies.d.ts +0 -158
- package/dist/cookies.js +0 -250
- package/dist/cookies.mjs +0 -221
- package/dist/dynamic-handle.d.ts +0 -15
- package/dist/dynamic-handle.js +0 -533
- package/dist/dynamic-handle.mjs +0 -521
- package/dist/formats.d.ts +0 -79
- package/dist/formats.js +0 -153
- package/dist/formats.mjs +0 -132
- package/dist/manifest.d.ts +0 -0
- package/dist/manifest.js +0 -1
- package/dist/manifest.mjs +0 -0
- package/dist/replace-schema.d.ts +0 -60
- package/dist/replace-schema.js +0 -140
- package/dist/replace-schema.mjs +0 -115
- package/dist/schema.d.ts +0 -107
- package/dist/schema.js +0 -833
- package/dist/schema.mjs +0 -814
- package/dist/type-system/format.d.ts +0 -55
- package/dist/type-system/format.js +0 -197
- package/dist/type-system/format.mjs +0 -175
- package/dist/type-system/index.d.ts +0 -45
- package/dist/type-system/index.js +0 -406
- package/dist/type-system/index.mjs +0 -394
- package/dist/type-system/types.d.ts +0 -155
- package/dist/type-system/types.js +0 -14
- package/dist/type-system/types.mjs +0 -0
- package/dist/type-system/utils.d.ts +0 -62
- package/dist/type-system/utils.js +0 -141
- package/dist/type-system/utils.mjs +0 -111
- package/dist/universal/request.d.ts +0 -29
- package/dist/universal/request.js +0 -126
- package/dist/universal/request.mjs +0 -105
- package/dist/universal/types.d.ts +0 -124
- package/dist/universal/types.js +0 -41
- package/dist/universal/types.mjs +0 -19
- package/dist/universal/utils.d.ts +0 -3
- package/dist/universal/utils.js +0 -41
- package/dist/universal/utils.mjs +0 -18
- package/dist/ws/bun.d.ts +0 -419
- package/dist/ws/bun.js +0 -14
- package/dist/ws/bun.mjs +0 -0
- package/knip.json +0 -22
|
@@ -1,382 +1,221 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_adapter_index = require('../index.js');
|
|
3
|
+
const require_constants = require('../../constants.js');
|
|
4
|
+
const require_utils = require('../../utils.js');
|
|
5
|
+
const require_adapter_web_standard_index = require('../web-standard/index.js');
|
|
6
|
+
const require_generation = require('../../generation.js');
|
|
7
|
+
const require_adapter_origin = require('../origin.js');
|
|
8
|
+
const require_compile_handler_index = require('../../compile/handler/index.js');
|
|
9
|
+
const require_route_table = require('../../route-table.js');
|
|
10
|
+
|
|
11
|
+
//#region src/adapter/bun/index.ts
|
|
12
|
+
/**
|
|
13
|
+
* ! This may looks like it would cause race condition, but it is not
|
|
14
|
+
* Bun is single-threaded and synchronous, so the `finally` block will
|
|
15
|
+
* always run before the next request comes in
|
|
16
|
+
* @see ../origin.ts
|
|
17
|
+
*
|
|
18
|
+
* `finally` runs on the synchronous return of `fetch` (the returned promise is
|
|
19
|
+
* not awaited), so the slot is live only for the handler's synchronous prologue
|
|
20
|
+
*/
|
|
21
|
+
const withOrigin = (fetch) => (request, server) => {
|
|
22
|
+
require_adapter_origin.origin.request = request;
|
|
23
|
+
try {
|
|
24
|
+
return fetch(request, server);
|
|
25
|
+
} finally {
|
|
26
|
+
require_adapter_origin.origin.request = void 0;
|
|
27
|
+
}
|
|
14
28
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
withAsync: !0
|
|
204
|
-
}),
|
|
205
|
-
mapRoutes(app)
|
|
206
|
-
),
|
|
207
|
-
// @ts-ignore
|
|
208
|
-
app.config.serve?.routes
|
|
209
|
-
)
|
|
210
|
-
);
|
|
211
|
-
app.server?.reload({
|
|
212
|
-
...serve,
|
|
213
|
-
fetch: app.fetch,
|
|
214
|
-
// @ts-ignore
|
|
215
|
-
routes: routes2
|
|
216
|
-
}), Bun?.gc(!1);
|
|
217
|
-
});
|
|
218
|
-
};
|
|
219
|
-
},
|
|
220
|
-
async stop(app, closeActiveConnections) {
|
|
221
|
-
if (app.server) {
|
|
222
|
-
if (await app.server.stop(closeActiveConnections), app.server = null, app.event.stop?.length)
|
|
223
|
-
for (let i = 0; i < app.event.stop.length; i++)
|
|
224
|
-
app.event.stop[i].fn(app);
|
|
225
|
-
} else
|
|
226
|
-
console.log(
|
|
227
|
-
"Elysia isn't running. Call `app.listen` to start the server.",
|
|
228
|
-
new Error().stack
|
|
229
|
-
);
|
|
230
|
-
},
|
|
231
|
-
ws(app, path, options) {
|
|
232
|
-
const { parse, body, response, ...rest } = options, messageValidator = (0, import_schema.getSchemaValidator)(body, {
|
|
233
|
-
// @ts-expect-error private property
|
|
234
|
-
modules: app.definitions.typebox,
|
|
235
|
-
// @ts-expect-error private property
|
|
236
|
-
models: app.definitions.type,
|
|
237
|
-
normalize: app.config.normalize
|
|
238
|
-
}), validateMessage = messageValidator ? messageValidator.provider === "standard" ? (data) => messageValidator.schema["~standard"].validate(data).issues : (data) => messageValidator.Check(data) === !1 : void 0, responseValidator = (0, import_schema.getSchemaValidator)(response, {
|
|
239
|
-
// @ts-expect-error private property
|
|
240
|
-
modules: app.definitions.typebox,
|
|
241
|
-
// @ts-expect-error private property
|
|
242
|
-
models: app.definitions.type,
|
|
243
|
-
normalize: app.config.normalize
|
|
244
|
-
});
|
|
245
|
-
app.route(
|
|
246
|
-
"WS",
|
|
247
|
-
path,
|
|
248
|
-
async (context) => {
|
|
249
|
-
const server = context.server ?? app.server, { set, path: path2, qi, headers, query, params } = context;
|
|
250
|
-
if (context.validator = responseValidator, options.upgrade)
|
|
251
|
-
if (typeof options.upgrade == "function") {
|
|
252
|
-
const temp = options.upgrade(context);
|
|
253
|
-
temp instanceof Promise && await temp;
|
|
254
|
-
} else options.upgrade && Object.assign(
|
|
255
|
-
set.headers,
|
|
256
|
-
options.upgrade
|
|
257
|
-
);
|
|
258
|
-
if (set.cookie && (0, import_utils2.isNotEmpty)(set.cookie)) {
|
|
259
|
-
const cookie = (0, import_cookies.serializeCookie)(set.cookie);
|
|
260
|
-
cookie && (set.headers["set-cookie"] = cookie);
|
|
261
|
-
}
|
|
262
|
-
set.headers["set-cookie"] && Array.isArray(set.headers["set-cookie"]) && (set.headers = (0, import_utils.parseSetCookies)(
|
|
263
|
-
new Headers(set.headers),
|
|
264
|
-
set.headers["set-cookie"]
|
|
265
|
-
));
|
|
266
|
-
const handleResponse = (0, import_ws.createHandleWSResponse)(responseValidator), parseMessage = (0, import_ws.createWSMessageParser)(parse);
|
|
267
|
-
let _id;
|
|
268
|
-
if (typeof options.beforeHandle == "function") {
|
|
269
|
-
const result = options.beforeHandle(context);
|
|
270
|
-
result instanceof Promise && await result;
|
|
271
|
-
}
|
|
272
|
-
const errorHandlers = [
|
|
273
|
-
...options.error ? Array.isArray(options.error) ? options.error : [options.error] : [],
|
|
274
|
-
...(app.event.error ?? []).map(
|
|
275
|
-
(x) => typeof x == "function" ? x : x.fn
|
|
276
|
-
)
|
|
277
|
-
].filter((x) => x), hasCustomErrorHandlers = errorHandlers.length > 0, handleErrors = hasCustomErrorHandlers ? async (ws, error) => {
|
|
278
|
-
for (const handleError of errorHandlers) {
|
|
279
|
-
let response2 = handleError(
|
|
280
|
-
Object.assign(context, { error })
|
|
281
|
-
);
|
|
282
|
-
if (response2 instanceof Promise && (response2 = await response2), await handleResponse(ws, response2), response2) break;
|
|
283
|
-
}
|
|
284
|
-
} : () => {
|
|
285
|
-
};
|
|
286
|
-
if (!server?.upgrade(context.request, {
|
|
287
|
-
headers: (0, import_utils2.isNotEmpty)(set.headers) ? set.headers : void 0,
|
|
288
|
-
data: {
|
|
289
|
-
...context,
|
|
290
|
-
get id() {
|
|
291
|
-
return _id || (_id = (0, import_utils2.randomId)());
|
|
292
|
-
},
|
|
293
|
-
validator: responseValidator,
|
|
294
|
-
ping(ws, data) {
|
|
295
|
-
options.ping?.(ws, data);
|
|
296
|
-
},
|
|
297
|
-
pong(ws, data) {
|
|
298
|
-
options.pong?.(ws, data);
|
|
299
|
-
},
|
|
300
|
-
open: async (ws) => {
|
|
301
|
-
try {
|
|
302
|
-
await handleResponse(
|
|
303
|
-
ws,
|
|
304
|
-
options.open?.(
|
|
305
|
-
new import_ws.ElysiaWS(ws, context)
|
|
306
|
-
)
|
|
307
|
-
);
|
|
308
|
-
} catch (error) {
|
|
309
|
-
handleErrors(ws, error);
|
|
310
|
-
}
|
|
311
|
-
},
|
|
312
|
-
message: async (ws, _message) => {
|
|
313
|
-
const message = await parseMessage(ws, _message);
|
|
314
|
-
if (validateMessage && validateMessage(message)) {
|
|
315
|
-
const validationError = new import_error.ValidationError(
|
|
316
|
-
"message",
|
|
317
|
-
messageValidator,
|
|
318
|
-
message
|
|
319
|
-
);
|
|
320
|
-
return hasCustomErrorHandlers ? handleErrors(ws, validationError) : void ws.send(
|
|
321
|
-
validationError.message
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
try {
|
|
325
|
-
await handleResponse(
|
|
326
|
-
ws,
|
|
327
|
-
options.message?.(
|
|
328
|
-
new import_ws.ElysiaWS(
|
|
329
|
-
ws,
|
|
330
|
-
context,
|
|
331
|
-
message
|
|
332
|
-
),
|
|
333
|
-
message
|
|
334
|
-
)
|
|
335
|
-
);
|
|
336
|
-
} catch (error) {
|
|
337
|
-
handleErrors(ws, error);
|
|
338
|
-
}
|
|
339
|
-
},
|
|
340
|
-
drain: async (ws) => {
|
|
341
|
-
try {
|
|
342
|
-
await handleResponse(
|
|
343
|
-
ws,
|
|
344
|
-
options.drain?.(
|
|
345
|
-
new import_ws.ElysiaWS(ws, context)
|
|
346
|
-
)
|
|
347
|
-
);
|
|
348
|
-
} catch (error) {
|
|
349
|
-
handleErrors(ws, error);
|
|
350
|
-
}
|
|
351
|
-
},
|
|
352
|
-
close: async (ws, code, reason) => {
|
|
353
|
-
try {
|
|
354
|
-
await handleResponse(
|
|
355
|
-
ws,
|
|
356
|
-
options.close?.(
|
|
357
|
-
new import_ws.ElysiaWS(ws, context),
|
|
358
|
-
code,
|
|
359
|
-
reason
|
|
360
|
-
)
|
|
361
|
-
);
|
|
362
|
-
} catch (error) {
|
|
363
|
-
handleErrors(ws, error);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}))
|
|
368
|
-
return (0, import_error.status)(400, "Expected a websocket connection");
|
|
369
|
-
},
|
|
370
|
-
{
|
|
371
|
-
...rest,
|
|
372
|
-
websocket: options
|
|
373
|
-
}
|
|
374
|
-
);
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
378
|
-
0 && (module.exports = {
|
|
379
|
-
BunAdapter,
|
|
380
|
-
isHTMLBundle,
|
|
381
|
-
removeTrailingPath
|
|
29
|
+
const nativeStaticMethods = new Set([
|
|
30
|
+
"GET",
|
|
31
|
+
"POST",
|
|
32
|
+
"PUT",
|
|
33
|
+
"DELETE",
|
|
34
|
+
"PATCH",
|
|
35
|
+
"HEAD",
|
|
36
|
+
"OPTIONS"
|
|
37
|
+
]);
|
|
38
|
+
function collectStaticRoutes(app) {
|
|
39
|
+
if (app["~config"]?.nativeStaticResponse === false) return;
|
|
40
|
+
app.fetch;
|
|
41
|
+
const frozenRoot = require_generation.frozenRootOf(app);
|
|
42
|
+
const fetchLevelHook = require_utils.flattenChain(frozenRoot["~hookChain"]);
|
|
43
|
+
if (fetchLevelHook?.request?.length || fetchLevelHook?.trace?.length || frozenRoot["~ext"]?.hoc?.length) return;
|
|
44
|
+
const table = app["~generation"]?.routeTable ?? app["~routeTable"];
|
|
45
|
+
const length = table?.length ?? 0;
|
|
46
|
+
if (!table || !length) return;
|
|
47
|
+
const methods = table.method;
|
|
48
|
+
const paths = table.path;
|
|
49
|
+
const handlers = table.handler;
|
|
50
|
+
let hasCandidate = false;
|
|
51
|
+
for (let i = 0; i < length; i++) {
|
|
52
|
+
const h = handlers[i];
|
|
53
|
+
if (typeof h === "function" || h instanceof Error || h instanceof Promise) continue;
|
|
54
|
+
if (!nativeStaticMethods.has(methods[i])) continue;
|
|
55
|
+
hasCandidate = true;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
if (!hasCandidate) return;
|
|
59
|
+
const ready = require_utils.nullObject();
|
|
60
|
+
const strictPath = frozenRoot["~config"]?.strictPath === true;
|
|
61
|
+
const seen = /* @__PURE__ */ new Map();
|
|
62
|
+
for (let i = 0; i < length; i++) seen.set(methods[i] + " " + paths[i], i);
|
|
63
|
+
let explicitPaths;
|
|
64
|
+
if (!strictPath) {
|
|
65
|
+
explicitPaths = /* @__PURE__ */ new Map();
|
|
66
|
+
for (let i = 0; i < length; i++) {
|
|
67
|
+
const method = methods[i];
|
|
68
|
+
const path = paths[i];
|
|
69
|
+
let set = explicitPaths.get(method);
|
|
70
|
+
if (!set) explicitPaths.set(method, set = /* @__PURE__ */ new Set());
|
|
71
|
+
set.add(path);
|
|
72
|
+
if (require_constants.needEncodeRegex.test(path)) {
|
|
73
|
+
const encoded = encodeURI(path);
|
|
74
|
+
if (encoded !== path) set.add(encoded);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const add = (method, path, value) => {
|
|
79
|
+
if (require_constants.needEncodeRegex.test(path)) path = encodeURI(path);
|
|
80
|
+
(ready[path] ??= require_utils.nullObject())[method] = value;
|
|
81
|
+
};
|
|
82
|
+
for (let i = 0; i < length; i++) {
|
|
83
|
+
const method = methods[i];
|
|
84
|
+
if (method === "WS") continue;
|
|
85
|
+
const path = paths[i];
|
|
86
|
+
if (seen.get(method + " " + path) !== i) continue;
|
|
87
|
+
if (!nativeStaticMethods.has(method)) continue;
|
|
88
|
+
const h = handlers[i];
|
|
89
|
+
if (typeof h === "function" || h instanceof Error || h instanceof Promise) continue;
|
|
90
|
+
const value = require_compile_handler_index.buildNativeStaticResponse(require_route_table.routeRow(table, i), app);
|
|
91
|
+
if (!value) continue;
|
|
92
|
+
add(method, path, value);
|
|
93
|
+
if (!strictPath && !require_constants.isDynamicRegex.test(path)) {
|
|
94
|
+
const loose = require_utils.getLoosePath(path);
|
|
95
|
+
if (loose !== path && !explicitPaths?.get(method)?.has(loose)) add(method, loose, value);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (!Object.keys(ready).length) return;
|
|
99
|
+
return [ready, []];
|
|
100
|
+
}
|
|
101
|
+
const BunAdapter = require_adapter_index.createAdapter({
|
|
102
|
+
name: "bun",
|
|
103
|
+
runtime: "bun",
|
|
104
|
+
isWebStandard: true,
|
|
105
|
+
parse: require_adapter_web_standard_index.WebStandardAdapter.parse,
|
|
106
|
+
response: require_adapter_web_standard_index.WebStandardAdapter.response,
|
|
107
|
+
listen(app, options, callback) {
|
|
108
|
+
const _config = app["~config"]?.serve;
|
|
109
|
+
const optionsIsObject = typeof options === "object";
|
|
110
|
+
let live;
|
|
111
|
+
const gatedFetch = (request, server) => live ? live(request, server) : Promise.resolve(ready).then(() => {
|
|
112
|
+
if (!live) throw new Error("[Elysia] Server was stopped before it was ready");
|
|
113
|
+
return live(request, server);
|
|
114
|
+
});
|
|
115
|
+
const _options = optionsIsObject ? { ...options } : {
|
|
116
|
+
port: +options,
|
|
117
|
+
fetch: gatedFetch
|
|
118
|
+
};
|
|
119
|
+
if (optionsIsObject) _options.fetch = gatedFetch;
|
|
120
|
+
const serve = _config ? {
|
|
121
|
+
..._config,
|
|
122
|
+
..._options
|
|
123
|
+
} : _options;
|
|
124
|
+
let ready;
|
|
125
|
+
const build = () => {
|
|
126
|
+
const fetch = app.fetch;
|
|
127
|
+
let routes;
|
|
128
|
+
try {
|
|
129
|
+
routes = collectStaticRoutes(app);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
console.warn("[Elysia] Native static promotion was skipped:", error);
|
|
132
|
+
}
|
|
133
|
+
let websocket;
|
|
134
|
+
if (app["~hasWS"]) {
|
|
135
|
+
const resolved = require_generation.resolvedWsOf(app);
|
|
136
|
+
if (!resolved) throw new Error("[Elysia] internal: WebSocket routes are present but no capability provider was resolved");
|
|
137
|
+
websocket = resolved.config ? Object.assign(resolved.provider.buildGlobalWSHandler(), resolved.config) : resolved.provider.buildGlobalWSHandler();
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
fetch,
|
|
141
|
+
routes,
|
|
142
|
+
websocket
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
let built;
|
|
146
|
+
const server = app.server = Bun.serve(serve);
|
|
147
|
+
const reload = () => {
|
|
148
|
+
try {
|
|
149
|
+
server.reload(serve);
|
|
150
|
+
} catch (error) {
|
|
151
|
+
if (!serve.routes) throw error;
|
|
152
|
+
delete serve.routes;
|
|
153
|
+
console.warn("[Elysia] Native static promotion was skipped:", error);
|
|
154
|
+
try {
|
|
155
|
+
server.reload(serve);
|
|
156
|
+
} catch (fallbackError) {
|
|
157
|
+
console.error("[Elysia] Failed to reload Bun server:", fallbackError);
|
|
158
|
+
throw fallbackError;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const setup = () => {
|
|
163
|
+
const onSetup = app["~ext"]?.setup;
|
|
164
|
+
if (!onSetup) return;
|
|
165
|
+
let pendingSetups;
|
|
166
|
+
for (let i = 0; i < onSetup.length; i++) {
|
|
167
|
+
const result = onSetup[i](app);
|
|
168
|
+
if (result && typeof result.then === "function") (pendingSetups ??= []).push(result);
|
|
169
|
+
}
|
|
170
|
+
if (pendingSetups) return Promise.all(pendingSetups);
|
|
171
|
+
};
|
|
172
|
+
const rollback = (error) => {
|
|
173
|
+
if (app.server !== server) return;
|
|
174
|
+
try {
|
|
175
|
+
server.stop(true);
|
|
176
|
+
} catch (stopError) {
|
|
177
|
+
console.error(stopError);
|
|
178
|
+
} finally {
|
|
179
|
+
app.server = void 0;
|
|
180
|
+
}
|
|
181
|
+
const cleanup = app["~ext"]?.cleanup;
|
|
182
|
+
if (cleanup) for (let i = cleanup.length - 1; i >= 0; i--) try {
|
|
183
|
+
const result = cleanup[i](app);
|
|
184
|
+
if (result && typeof result.then === "function") Promise.resolve(result).catch(console.error);
|
|
185
|
+
} catch (cleanupError) {
|
|
186
|
+
console.error(cleanupError);
|
|
187
|
+
}
|
|
188
|
+
return error;
|
|
189
|
+
};
|
|
190
|
+
const publish = () => {
|
|
191
|
+
if (app.server !== server) return;
|
|
192
|
+
built ??= build();
|
|
193
|
+
live = serve.fetch = withOrigin(built.fetch);
|
|
194
|
+
if (built.websocket) serve.websocket = built.websocket;
|
|
195
|
+
if (built.routes) serve.routes = built.routes[0];
|
|
196
|
+
reload();
|
|
197
|
+
if (callback) callback(server);
|
|
198
|
+
};
|
|
199
|
+
const start = () => {
|
|
200
|
+
if (app.server !== server) return;
|
|
201
|
+
const setupReady = setup();
|
|
202
|
+
if (setupReady && typeof setupReady.then === "function") return Promise.resolve(setupReady).then(publish);
|
|
203
|
+
publish();
|
|
204
|
+
};
|
|
205
|
+
try {
|
|
206
|
+
if (app.pending) ready = app.modules.then(start);
|
|
207
|
+
else ready = Promise.resolve().then(start);
|
|
208
|
+
ready.catch((error) => {
|
|
209
|
+
console.error("[Elysia] listen() failed:", error);
|
|
210
|
+
return rollback(error);
|
|
211
|
+
});
|
|
212
|
+
} catch (error) {
|
|
213
|
+
rollback(error);
|
|
214
|
+
throw error;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
382
217
|
});
|
|
218
|
+
|
|
219
|
+
//#endregion
|
|
220
|
+
exports.BunAdapter = BunAdapter;
|
|
221
|
+
exports.collectStaticRoutes = collectStaticRoutes;
|