elysia 2.0.0-exp.55 → 2.0.0-exp.56
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.js +15 -16
- package/dist/adapter/bun/index.mjs +15 -16
- package/dist/package.js +1 -1
- package/dist/package.mjs +1 -1
- package/dist/type/coerce.d.ts +1 -1
- package/dist/type/constants.d.ts +1 -1
- package/package.json +1 -1
|
@@ -107,17 +107,20 @@ const BunAdapter = require_adapter_index.createAdapter({
|
|
|
107
107
|
listen(app, options, callback) {
|
|
108
108
|
const _config = app["~config"]?.serve;
|
|
109
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
|
+
});
|
|
110
115
|
const _options = optionsIsObject ? { ...options } : {
|
|
111
116
|
port: +options,
|
|
112
|
-
fetch:
|
|
117
|
+
fetch: gatedFetch
|
|
113
118
|
};
|
|
114
|
-
if (optionsIsObject) _options.fetch =
|
|
119
|
+
if (optionsIsObject) _options.fetch = gatedFetch;
|
|
115
120
|
const serve = _config ? {
|
|
116
121
|
..._config,
|
|
117
122
|
..._options
|
|
118
123
|
} : _options;
|
|
119
|
-
const onSetup = app["~ext"]?.setup;
|
|
120
|
-
const needsGate = app.pending || !!onSetup?.length;
|
|
121
124
|
let ready;
|
|
122
125
|
const build = () => {
|
|
123
126
|
const fetch = app.fetch;
|
|
@@ -130,7 +133,7 @@ const BunAdapter = require_adapter_index.createAdapter({
|
|
|
130
133
|
let websocket;
|
|
131
134
|
if (app["~hasWS"]) {
|
|
132
135
|
const resolved = require_generation.resolvedWsOf(app);
|
|
133
|
-
if (!resolved) throw new Error("[Elysia] internal: WebSocket routes are present but no capability provider was resolved
|
|
136
|
+
if (!resolved) throw new Error("[Elysia] internal: WebSocket routes are present but no capability provider was resolved");
|
|
134
137
|
websocket = resolved.config ? Object.assign(resolved.provider.buildGlobalWSHandler(), resolved.config) : resolved.provider.buildGlobalWSHandler();
|
|
135
138
|
}
|
|
136
139
|
return {
|
|
@@ -140,9 +143,6 @@ const BunAdapter = require_adapter_index.createAdapter({
|
|
|
140
143
|
};
|
|
141
144
|
};
|
|
142
145
|
let built;
|
|
143
|
-
if (!needsGate) built = build();
|
|
144
|
-
if (needsGate) serve.fetch = (request, server) => ready.then(() => app.fetch(request, server));
|
|
145
|
-
else serve.fetch = withOrigin(built.fetch);
|
|
146
146
|
const server = app.server = Bun.serve(serve);
|
|
147
147
|
const reload = () => {
|
|
148
148
|
try {
|
|
@@ -190,10 +190,10 @@ const BunAdapter = require_adapter_index.createAdapter({
|
|
|
190
190
|
const publish = () => {
|
|
191
191
|
if (app.server !== server) return;
|
|
192
192
|
built ??= build();
|
|
193
|
-
serve.fetch = withOrigin(built.fetch);
|
|
193
|
+
live = serve.fetch = withOrigin(built.fetch);
|
|
194
194
|
if (built.websocket) serve.websocket = built.websocket;
|
|
195
195
|
if (built.routes) serve.routes = built.routes[0];
|
|
196
|
-
|
|
196
|
+
reload();
|
|
197
197
|
if (callback) callback(server);
|
|
198
198
|
};
|
|
199
199
|
const start = () => {
|
|
@@ -204,12 +204,11 @@ const BunAdapter = require_adapter_index.createAdapter({
|
|
|
204
204
|
};
|
|
205
205
|
try {
|
|
206
206
|
if (app.pending) ready = app.modules.then(start);
|
|
207
|
-
else
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
ready?.catch(rollback);
|
|
207
|
+
else ready = Promise.resolve().then(start);
|
|
208
|
+
ready.catch((error) => {
|
|
209
|
+
console.error("[Elysia] listen() failed:", error);
|
|
210
|
+
return rollback(error);
|
|
211
|
+
});
|
|
213
212
|
} catch (error) {
|
|
214
213
|
rollback(error);
|
|
215
214
|
throw error;
|
|
@@ -106,17 +106,20 @@ const BunAdapter = createAdapter({
|
|
|
106
106
|
listen(app, options, callback) {
|
|
107
107
|
const _config = app["~config"]?.serve;
|
|
108
108
|
const optionsIsObject = typeof options === "object";
|
|
109
|
+
let live;
|
|
110
|
+
const gatedFetch = (request, server) => live ? live(request, server) : Promise.resolve(ready).then(() => {
|
|
111
|
+
if (!live) throw new Error("[Elysia] Server was stopped before it was ready");
|
|
112
|
+
return live(request, server);
|
|
113
|
+
});
|
|
109
114
|
const _options = optionsIsObject ? { ...options } : {
|
|
110
115
|
port: +options,
|
|
111
|
-
fetch:
|
|
116
|
+
fetch: gatedFetch
|
|
112
117
|
};
|
|
113
|
-
if (optionsIsObject) _options.fetch =
|
|
118
|
+
if (optionsIsObject) _options.fetch = gatedFetch;
|
|
114
119
|
const serve = _config ? {
|
|
115
120
|
..._config,
|
|
116
121
|
..._options
|
|
117
122
|
} : _options;
|
|
118
|
-
const onSetup = app["~ext"]?.setup;
|
|
119
|
-
const needsGate = app.pending || !!onSetup?.length;
|
|
120
123
|
let ready;
|
|
121
124
|
const build = () => {
|
|
122
125
|
const fetch = app.fetch;
|
|
@@ -129,7 +132,7 @@ const BunAdapter = createAdapter({
|
|
|
129
132
|
let websocket;
|
|
130
133
|
if (app["~hasWS"]) {
|
|
131
134
|
const resolved = resolvedWsOf(app);
|
|
132
|
-
if (!resolved) throw new Error("[Elysia] internal: WebSocket routes are present but no capability provider was resolved
|
|
135
|
+
if (!resolved) throw new Error("[Elysia] internal: WebSocket routes are present but no capability provider was resolved");
|
|
133
136
|
websocket = resolved.config ? Object.assign(resolved.provider.buildGlobalWSHandler(), resolved.config) : resolved.provider.buildGlobalWSHandler();
|
|
134
137
|
}
|
|
135
138
|
return {
|
|
@@ -139,9 +142,6 @@ const BunAdapter = createAdapter({
|
|
|
139
142
|
};
|
|
140
143
|
};
|
|
141
144
|
let built;
|
|
142
|
-
if (!needsGate) built = build();
|
|
143
|
-
if (needsGate) serve.fetch = (request, server) => ready.then(() => app.fetch(request, server));
|
|
144
|
-
else serve.fetch = withOrigin(built.fetch);
|
|
145
145
|
const server = app.server = Bun.serve(serve);
|
|
146
146
|
const reload = () => {
|
|
147
147
|
try {
|
|
@@ -189,10 +189,10 @@ const BunAdapter = createAdapter({
|
|
|
189
189
|
const publish = () => {
|
|
190
190
|
if (app.server !== server) return;
|
|
191
191
|
built ??= build();
|
|
192
|
-
serve.fetch = withOrigin(built.fetch);
|
|
192
|
+
live = serve.fetch = withOrigin(built.fetch);
|
|
193
193
|
if (built.websocket) serve.websocket = built.websocket;
|
|
194
194
|
if (built.routes) serve.routes = built.routes[0];
|
|
195
|
-
|
|
195
|
+
reload();
|
|
196
196
|
if (callback) callback(server);
|
|
197
197
|
};
|
|
198
198
|
const start = () => {
|
|
@@ -203,12 +203,11 @@ const BunAdapter = createAdapter({
|
|
|
203
203
|
};
|
|
204
204
|
try {
|
|
205
205
|
if (app.pending) ready = app.modules.then(start);
|
|
206
|
-
else
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
ready?.catch(rollback);
|
|
206
|
+
else ready = Promise.resolve().then(start);
|
|
207
|
+
ready.catch((error) => {
|
|
208
|
+
console.error("[Elysia] listen() failed:", error);
|
|
209
|
+
return rollback(error);
|
|
210
|
+
});
|
|
212
211
|
} catch (error) {
|
|
213
212
|
rollback(error);
|
|
214
213
|
throw error;
|
package/dist/package.js
CHANGED
package/dist/package.mjs
CHANGED
package/dist/type/coerce.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ declare const coerceQuery: () => CoerceOption[];
|
|
|
34
34
|
declare const coerceBody: () => CoerceOption[];
|
|
35
35
|
declare const coerceFormData: () => CoerceOption[];
|
|
36
36
|
declare const coerceStringToStructure: () => CoerceOption[];
|
|
37
|
-
declare function applyCoercions(schema: BaseSchema | TSchema, coerces: CoerceOption[] | undefined):
|
|
37
|
+
declare function applyCoercions(schema: BaseSchema | TSchema, coerces: CoerceOption[] | undefined): TSchema | BaseSchema;
|
|
38
38
|
declare function captureCoercePlan(original: any, coerced: any): CoercePlan | null;
|
|
39
39
|
/** Full rebuild: scalar leaves + ObjectString/ArrayString sites (wired path). */
|
|
40
40
|
declare const buildCoercedFromPlan: (original: any, plan: CoercePlan, seen?: Set<string>) => any;
|
package/dist/type/constants.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ declare const ELYSIA_TYPES: {
|
|
|
17
17
|
readonly NoValidate: 15;
|
|
18
18
|
};
|
|
19
19
|
type ELYSIA_TYPES = typeof ELYSIA_TYPES;
|
|
20
|
-
declare const primitiveElysiaTypes: Set<
|
|
20
|
+
declare const primitiveElysiaTypes: Set<1 | 2 | 6 | 3 | 10 | 11 | 13 | 14>;
|
|
21
21
|
declare const noEnumerable: {
|
|
22
22
|
readonly enumerable: false;
|
|
23
23
|
};
|