elysia 2.0.0-beta.2 → 2.0.0-beta.4
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 +1 -1
- package/dist/adapter/bun/index.js +320 -56
- package/dist/adapter/bun/index.mjs +321 -57
- package/dist/adapter/utils.js +51 -30
- package/dist/adapter/utils.mjs +52 -31
- package/dist/adapter/web-standard/handler.js +5 -2
- package/dist/adapter/web-standard/handler.mjs +5 -2
- package/dist/base.d.ts +18 -7
- package/dist/base.js +213 -101
- package/dist/base.mjs +215 -103
- package/dist/compile/aot-capture.js +1 -1
- package/dist/compile/aot-capture.mjs +1 -1
- package/dist/compile/aot.d.ts +5 -4
- package/dist/compile/aot.js +17 -9
- package/dist/compile/aot.mjs +18 -9
- package/dist/compile/handler/descriptor.js +1 -1
- package/dist/compile/handler/descriptor.mjs +1 -1
- package/dist/compile/handler/frozen-validator.d.ts +4 -1
- package/dist/compile/handler/frozen-validator.js +8 -3
- package/dist/compile/handler/frozen-validator.mjs +5 -3
- package/dist/compile/handler/index.d.ts +2 -2
- package/dist/compile/handler/index.js +8 -6
- package/dist/compile/handler/index.mjs +8 -6
- package/dist/compile/handler/reconstruct.d.ts +1 -1
- package/dist/compile/handler/reconstruct.js +4 -3
- package/dist/compile/handler/reconstruct.mjs +4 -3
- package/dist/compile/handler/utils.js +2 -2
- package/dist/compile/handler/utils.mjs +3 -3
- package/dist/compile/jit-probe.d.ts +2 -2
- package/dist/context.d.ts +1 -1
- package/dist/context.js +8 -5
- package/dist/context.mjs +8 -5
- package/dist/cookie/config.d.ts +1 -0
- package/dist/cookie/config.js +3 -2
- package/dist/cookie/config.mjs +3 -2
- package/dist/cookie/cookie.d.ts +1 -0
- package/dist/cookie/cookie.js +6 -5
- package/dist/cookie/cookie.mjs +6 -5
- package/dist/cookie/crypto.d.ts +8 -7
- package/dist/cookie/crypto.js +38 -31
- package/dist/cookie/crypto.mjs +38 -32
- package/dist/cookie/error.js +1 -2
- package/dist/cookie/error.mjs +1 -2
- package/dist/cookie/lib.js +5 -1
- package/dist/cookie/lib.mjs +5 -1
- package/dist/cookie/serialize.js +1 -1
- package/dist/cookie/serialize.mjs +1 -1
- package/dist/cookie/types.d.ts +10 -0
- package/dist/cookie/utils.js +28 -14
- package/dist/cookie/utils.mjs +29 -15
- package/dist/handler/error.d.ts +23 -12
- package/dist/handler/error.js +24 -21
- package/dist/handler/error.mjs +20 -21
- package/dist/handler/fetch.js +6 -7
- package/dist/handler/fetch.mjs +7 -8
- package/dist/handler/utils.js +4 -2
- package/dist/handler/utils.mjs +5 -3
- package/dist/index.js +1 -8
- package/dist/package.js +1 -1
- package/dist/package.mjs +1 -1
- package/dist/plugin/aot/core.d.ts +33 -6
- package/dist/plugin/aot/core.js +120 -40
- package/dist/plugin/aot/core.mjs +121 -43
- package/dist/plugin/aot/esbuild.js +8 -2
- package/dist/plugin/aot/esbuild.mjs +9 -3
- package/dist/plugin/aot/hooks.d.ts +2 -1
- package/dist/plugin/aot/hooks.js +3 -3
- package/dist/plugin/aot/hooks.mjs +4 -4
- package/dist/plugin/aot/source.d.ts +4 -1
- package/dist/plugin/aot/source.js +21 -14
- package/dist/plugin/aot/source.mjs +21 -14
- package/dist/plugin/aot/worker.js +2 -2
- package/dist/plugin/aot/worker.mjs +2 -2
- package/dist/route-table.d.ts +3 -0
- package/dist/route-table.js +16 -11
- package/dist/route-table.mjs +16 -11
- package/dist/schema-snapshot.js +17 -22
- package/dist/schema-snapshot.mjs +17 -22
- package/dist/type/bridge-live.d.ts +1 -1
- package/dist/type/bridge-live.js +2 -2
- package/dist/type/bridge-live.mjs +2 -2
- package/dist/type/bridge.d.ts +1 -1
- package/dist/type/coerce-plan.js +3 -4
- package/dist/type/coerce-plan.mjs +1 -1
- package/dist/type/coerce.d.ts +1 -1
- package/dist/type/compat.d.ts +3 -0
- package/dist/type/compat.js +32 -14
- package/dist/type/compat.mjs +27 -8
- package/dist/type/constants.d.ts +1 -1
- package/dist/type/elysia/array-buffer.js +2 -3
- package/dist/type/elysia/array-buffer.mjs +1 -1
- package/dist/type/elysia/array-string.js +7 -4
- package/dist/type/elysia/array-string.mjs +9 -5
- package/dist/type/elysia/boolean-string.js +2 -3
- package/dist/type/elysia/boolean-string.mjs +1 -1
- package/dist/type/elysia/boolean.js +4 -3
- package/dist/type/elysia/boolean.mjs +4 -2
- package/dist/type/elysia/cookie.js +2 -1
- package/dist/type/elysia/cookie.mjs +2 -1
- package/dist/type/elysia/date.js +7 -7
- package/dist/type/elysia/date.mjs +3 -2
- package/dist/type/elysia/file-type.d.ts +9 -2
- package/dist/type/elysia/file-type.js +16 -1
- package/dist/type/elysia/file-type.mjs +16 -2
- package/dist/type/elysia/file.js +8 -4
- package/dist/type/elysia/file.mjs +8 -3
- package/dist/type/elysia/files.js +6 -4
- package/dist/type/elysia/files.mjs +5 -2
- package/dist/type/elysia/form.js +2 -3
- package/dist/type/elysia/form.mjs +3 -3
- package/dist/type/elysia/integer-string.js +4 -5
- package/dist/type/elysia/integer-string.mjs +3 -3
- package/dist/type/elysia/integer.js +4 -3
- package/dist/type/elysia/integer.mjs +4 -2
- package/dist/type/elysia/maybe-empty.js +3 -4
- package/dist/type/elysia/maybe-empty.mjs +1 -1
- package/dist/type/elysia/nullable.js +2 -3
- package/dist/type/elysia/nullable.mjs +1 -1
- package/dist/type/elysia/number.js +4 -3
- package/dist/type/elysia/number.mjs +4 -2
- package/dist/type/elysia/numeric-enum.js +2 -3
- package/dist/type/elysia/numeric-enum.mjs +1 -1
- package/dist/type/elysia/numeric.js +5 -5
- package/dist/type/elysia/numeric.mjs +3 -2
- package/dist/type/elysia/object-string.js +7 -4
- package/dist/type/elysia/object-string.mjs +9 -5
- package/dist/type/elysia/string.js +4 -3
- package/dist/type/elysia/string.mjs +4 -2
- package/dist/type/elysia/uint8-array.js +2 -3
- package/dist/type/elysia/uint8-array.mjs +1 -1
- package/dist/type/elysia/union-enum.js +2 -3
- package/dist/type/elysia/union-enum.mjs +1 -1
- package/dist/type/elysia/utils.js +2 -3
- package/dist/type/elysia/utils.mjs +1 -1
- package/dist/type/exports.js +10 -1
- package/dist/type/exports.mjs +7 -0
- package/dist/type/index.d.ts +9 -1
- package/dist/type/index.js +41 -13
- package/dist/type/index.mjs +44 -9
- package/dist/type/typebox-type-live.d.ts +9 -0
- package/dist/type/typebox-type-live.js +31 -0
- package/dist/type/typebox-type-live.mjs +16 -0
- package/dist/type/typebox-type.d.ts +24 -0
- package/dist/type/typebox-type.js +130 -0
- package/dist/type/typebox-type.mjs +66 -0
- package/dist/type/typebox-value-live.d.ts +9 -0
- package/dist/type/typebox-value-live.js +27 -0
- package/dist/type/typebox-value-live.mjs +11 -0
- package/dist/type/typebox-value.d.ts +30 -0
- package/dist/type/typebox-value.js +147 -0
- package/dist/type/typebox-value.mjs +62 -0
- package/dist/type/validator/custom-error.js +4 -5
- package/dist/type/validator/custom-error.mjs +3 -3
- package/dist/type/validator/default-precompute.js +4 -5
- package/dist/type/validator/default-precompute.mjs +1 -1
- package/dist/type/validator/index.d.ts +1 -1
- package/dist/type/validator/index.js +51 -42
- package/dist/type/validator/index.mjs +33 -23
- package/dist/type/validator/validator-cache.d.ts +1 -1
- package/dist/type/validator/validator-cache.js +27 -14
- package/dist/type/validator/validator-cache.mjs +27 -13
- package/dist/universal/constants.d.ts +2 -1
- package/dist/universal/constants.js +3 -1
- package/dist/universal/constants.mjs +2 -1
- package/dist/utils.d.ts +19 -1
- package/dist/utils.js +25 -3
- package/dist/utils.mjs +19 -3
- package/dist/validator/index.js +2 -1
- package/dist/validator/index.mjs +2 -1
- package/dist/ws/context.d.ts +8 -1
- package/dist/ws/context.js +65 -29
- package/dist/ws/context.mjs +64 -29
- package/dist/ws/route.js +176 -28
- package/dist/ws/route.mjs +179 -31
- package/package.json +5 -3
package/dist/adapter/utils.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hasHeaderShorthand, isBun } from "../universal/constants.mjs";
|
|
2
2
|
import { StatusMap } from "../constants.mjs";
|
|
3
|
-
import { isByteStream, isNotEmpty, nullObject } from "../utils.mjs";
|
|
3
|
+
import { isByteStream, isNotEmpty, nullObject, sseData } from "../utils.mjs";
|
|
4
4
|
import { skipClone } from "./skip-clone.mjs";
|
|
5
5
|
import { serializeCookie } from "../cookie/serialize.mjs";
|
|
6
6
|
import { isBorrowedResponse } from "./response-ownership.mjs";
|
|
@@ -13,7 +13,7 @@ function materializeSetHeaders(set) {
|
|
|
13
13
|
if (headers["\0"] !== headers) return headers;
|
|
14
14
|
return set.headers = Object.assign(nullObject(), headers);
|
|
15
15
|
}
|
|
16
|
-
const sseFormat = (data) =>
|
|
16
|
+
const sseFormat = (data) => sseData(data) + "\n";
|
|
17
17
|
const identityFormat = (data) => data;
|
|
18
18
|
const textEncoder = new TextEncoder();
|
|
19
19
|
const encodeChunk = (s) => textEncoder.encode(s);
|
|
@@ -157,10 +157,12 @@ function createStreamHandler({ mapResponse, mapCompactResponse }) {
|
|
|
157
157
|
return new Response(generator, { headers: { "content-type": "application/octet-stream" } });
|
|
158
158
|
}
|
|
159
159
|
const typedSSE = !skipFormat && "sse" in generator && generator.sse === true;
|
|
160
|
+
const sourceIterator = typeof generator.next === "function" ? generator : void 0;
|
|
160
161
|
let init = typedSSE ? void 0 : generator.next?.();
|
|
161
162
|
if (set) handleSet(set);
|
|
162
163
|
if (init instanceof Promise) init = await init;
|
|
163
|
-
|
|
164
|
+
const yieldedStream = init?.value instanceof ReadableStream;
|
|
165
|
+
if (yieldedStream) generator = init.value;
|
|
164
166
|
else if (init && (typeof init?.done === "undefined" || init?.done)) {
|
|
165
167
|
if (set) return mapResponse(init.value, set, request, owned);
|
|
166
168
|
return mapCompactResponse(init.value, request, owned);
|
|
@@ -194,8 +196,32 @@ function createStreamHandler({ mapResponse, mapCompactResponse }) {
|
|
|
194
196
|
connection: "keep-alive"
|
|
195
197
|
}
|
|
196
198
|
};
|
|
197
|
-
const
|
|
199
|
+
const sourceStream = generator instanceof ReadableStream ? generator : void 0;
|
|
200
|
+
let streamReader;
|
|
201
|
+
const iterator = sourceStream ? {
|
|
202
|
+
next: () => (streamReader ??= sourceStream.getReader()).read(),
|
|
203
|
+
async return() {
|
|
204
|
+
if (!streamReader) {
|
|
205
|
+
await sourceStream.cancel();
|
|
206
|
+
return {
|
|
207
|
+
done: true,
|
|
208
|
+
value: void 0
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
try {
|
|
212
|
+
await streamReader.cancel();
|
|
213
|
+
} finally {
|
|
214
|
+
streamReader.releaseLock();
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
done: true,
|
|
218
|
+
value: void 0
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
} : sourceIterator ?? generator[Symbol.asyncIterator]();
|
|
222
|
+
const outerIterator = yieldedStream && !init.done ? sourceIterator : void 0;
|
|
198
223
|
let end = false;
|
|
224
|
+
let finalizing;
|
|
199
225
|
const signal = request?.signal;
|
|
200
226
|
let onAbort;
|
|
201
227
|
const cleanupAbort = () => {
|
|
@@ -204,17 +230,21 @@ function createStreamHandler({ mapResponse, mapCompactResponse }) {
|
|
|
204
230
|
onAbort = void 0;
|
|
205
231
|
}
|
|
206
232
|
};
|
|
207
|
-
const safeReturn = () => {
|
|
233
|
+
const safeReturn = async (target) => {
|
|
208
234
|
try {
|
|
209
|
-
|
|
210
|
-
if (r && typeof r.then === "function") r.catch(() => {});
|
|
235
|
+
await target?.return?.();
|
|
211
236
|
} catch {}
|
|
212
237
|
};
|
|
213
|
-
const
|
|
238
|
+
const finalize = (mode, controller, error) => {
|
|
239
|
+
if (end) return finalizing;
|
|
240
|
+
end = true;
|
|
241
|
+
cleanupAbort();
|
|
242
|
+
finalizing = safeReturn(iterator).then(() => safeReturn(outerIterator));
|
|
243
|
+
if (!controller) return finalizing;
|
|
214
244
|
try {
|
|
215
|
-
controller.
|
|
245
|
+
if (mode === "error") controller.error(error);
|
|
246
|
+
else controller.close();
|
|
216
247
|
} catch {}
|
|
217
|
-
cleanupAbort();
|
|
218
248
|
};
|
|
219
249
|
const enqueueValue = async (controller, value) => {
|
|
220
250
|
if (value.toSSE) {
|
|
@@ -233,42 +263,33 @@ function createStreamHandler({ mapResponse, mapCompactResponse }) {
|
|
|
233
263
|
return new Response(new ReadableStream({
|
|
234
264
|
async start(controller) {
|
|
235
265
|
if (signal) {
|
|
236
|
-
onAbort = () =>
|
|
237
|
-
cleanupAbort();
|
|
238
|
-
end = true;
|
|
239
|
-
safeReturn();
|
|
240
|
-
try {
|
|
241
|
-
controller.close();
|
|
242
|
-
} catch {}
|
|
243
|
-
};
|
|
266
|
+
onAbort = () => finalize("close", controller);
|
|
244
267
|
if (signal.aborted) onAbort();
|
|
245
268
|
else signal.addEventListener("abort", onAbort, { once: true });
|
|
246
269
|
}
|
|
247
270
|
if (!init || init.value instanceof ReadableStream || init.value === void 0 || init.value === null) return;
|
|
248
|
-
|
|
271
|
+
try {
|
|
272
|
+
await enqueueValue(controller, init.value);
|
|
273
|
+
} catch (error) {
|
|
274
|
+
finalize("error", controller, error);
|
|
275
|
+
}
|
|
249
276
|
},
|
|
250
277
|
async pull(controller) {
|
|
251
|
-
if (end)
|
|
252
|
-
closeSafely(controller);
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
278
|
+
if (end) return;
|
|
255
279
|
try {
|
|
256
280
|
const { value: chunk, done } = await iterator.next();
|
|
257
281
|
if (done || end) {
|
|
258
|
-
|
|
282
|
+
finalize("close", controller);
|
|
259
283
|
return;
|
|
260
284
|
}
|
|
261
285
|
if (chunk === void 0 || chunk === null) return;
|
|
262
286
|
await enqueueValue(controller, chunk);
|
|
263
287
|
} catch (error) {
|
|
264
|
-
|
|
265
|
-
controller.error(error);
|
|
288
|
+
finalize("error", controller, error);
|
|
266
289
|
}
|
|
267
290
|
},
|
|
268
291
|
cancel() {
|
|
269
|
-
|
|
270
|
-
cleanupAbort();
|
|
271
|
-
safeReturn();
|
|
292
|
+
finalize("close");
|
|
272
293
|
}
|
|
273
294
|
}, typedSSE ? { highWaterMark: 0 } : void 0), set);
|
|
274
295
|
};
|
|
@@ -283,7 +304,7 @@ function handleSet(set) {
|
|
|
283
304
|
const proto = Object.getPrototypeOf(set.headers);
|
|
284
305
|
if (proto !== null && proto !== Object.prototype) {
|
|
285
306
|
const flat = Object.create(null);
|
|
286
|
-
for (const key
|
|
307
|
+
for (const key of Object.keys(set.headers)) flat[key] = set.headers[key];
|
|
287
308
|
set.headers = flat;
|
|
288
309
|
}
|
|
289
310
|
if (set.cookie && isNotEmpty(set.cookie)) {
|
|
@@ -310,7 +331,7 @@ function applySetHeaders(target, setHeaders, present) {
|
|
|
310
331
|
for (const key of setHeaders.keys()) if (key !== setCookie && !present.has(key)) target.set(key, setHeaders.get(key) ?? "");
|
|
311
332
|
} else {
|
|
312
333
|
let cookies;
|
|
313
|
-
for (const key
|
|
334
|
+
for (const key of Object.keys(setHeaders)) if (key === setCookie) {
|
|
314
335
|
const cookie = setHeaders[key];
|
|
315
336
|
cookies ??= target.getSetCookie();
|
|
316
337
|
if (!cookies.includes(cookie)) {
|
|
@@ -5,6 +5,7 @@ const require_utils = require('../../utils.js');
|
|
|
5
5
|
const require_error = require('../../error.js');
|
|
6
6
|
const require_adapter_default_headers = require('../default-headers.js');
|
|
7
7
|
const require_adapter_utils = require('../utils.js');
|
|
8
|
+
const require_cookie_cookie = require('../../cookie/cookie.js');
|
|
8
9
|
|
|
9
10
|
//#region src/adapter/web-standard/handler.ts
|
|
10
11
|
const textPlainInit = { headers: { "content-type": "text/plain" } };
|
|
@@ -23,7 +24,9 @@ function handleElysiaFile(file, set = { headers: require_utils.nullObject() }, r
|
|
|
23
24
|
}
|
|
24
25
|
function responseTag(response) {
|
|
25
26
|
if (response == null) return;
|
|
26
|
-
|
|
27
|
+
const constructor = Object.getPrototypeOf(response)?.constructor;
|
|
28
|
+
if (typeof constructor !== "function") return typeof response.next === "function" ? "" : void 0;
|
|
29
|
+
return constructor.name;
|
|
27
30
|
}
|
|
28
31
|
function mapResponseWithSet(response, set, request, owned) {
|
|
29
32
|
require_adapter_utils.handleSet(set);
|
|
@@ -134,7 +137,7 @@ function mapFallback(response, set, request, owned = false) {
|
|
|
134
137
|
if (typeof response?.then === "function") return response.then((x) => set ? mapResponse(x, set, request, owned) : mapCompactResponse(x, request, owned));
|
|
135
138
|
if (Array.isArray(response)) return Response.json(response);
|
|
136
139
|
if (typeof response?.toResponse === "function") return set ? mapResponse(response.toResponse(), set, request, owned) : mapCompactResponse(response.toResponse(), request, owned);
|
|
137
|
-
if (responseTag(response) === "Cookie") return set ? mapResponse(response.value, set, request, owned) : mapCompactResponse(response.value, request, owned);
|
|
140
|
+
if (responseTag(response) === "Cookie" && require_cookie_cookie.Cookie.isCookie(response)) return set ? mapResponse(response.value, set, request, owned) : mapCompactResponse(response.value, request, owned);
|
|
138
141
|
return new Response(response, set);
|
|
139
142
|
}
|
|
140
143
|
const handleResponse = require_adapter_utils.createResponseHandler({
|
|
@@ -4,6 +4,7 @@ import { formToFormData, isElysiaForm, isNotEmpty, nullObject } from "../../util
|
|
|
4
4
|
import { ElysiaStatus, PROBLEM_JSON, internalServerErrorBody } from "../../error.mjs";
|
|
5
5
|
import { defaultHeaders } from "../default-headers.mjs";
|
|
6
6
|
import { createResponseHandler, createStreamHandler, handleFile, handleSet, materializeSetHeaders } from "../utils.mjs";
|
|
7
|
+
import { Cookie } from "../../cookie/cookie.mjs";
|
|
7
8
|
|
|
8
9
|
//#region src/adapter/web-standard/handler.ts
|
|
9
10
|
const textPlainInit = { headers: { "content-type": "text/plain" } };
|
|
@@ -22,7 +23,9 @@ function handleElysiaFile(file, set = { headers: nullObject() }, request) {
|
|
|
22
23
|
}
|
|
23
24
|
function responseTag(response) {
|
|
24
25
|
if (response == null) return;
|
|
25
|
-
|
|
26
|
+
const constructor = Object.getPrototypeOf(response)?.constructor;
|
|
27
|
+
if (typeof constructor !== "function") return typeof response.next === "function" ? "" : void 0;
|
|
28
|
+
return constructor.name;
|
|
26
29
|
}
|
|
27
30
|
function mapResponseWithSet(response, set, request, owned) {
|
|
28
31
|
handleSet(set);
|
|
@@ -133,7 +136,7 @@ function mapFallback(response, set, request, owned = false) {
|
|
|
133
136
|
if (typeof response?.then === "function") return response.then((x) => set ? mapResponse(x, set, request, owned) : mapCompactResponse(x, request, owned));
|
|
134
137
|
if (Array.isArray(response)) return Response.json(response);
|
|
135
138
|
if (typeof response?.toResponse === "function") return set ? mapResponse(response.toResponse(), set, request, owned) : mapCompactResponse(response.toResponse(), request, owned);
|
|
136
|
-
if (responseTag(response) === "Cookie") return set ? mapResponse(response.value, set, request, owned) : mapCompactResponse(response.value, request, owned);
|
|
139
|
+
if (responseTag(response) === "Cookie" && Cookie.isCookie(response)) return set ? mapResponse(response.value, set, request, owned) : mapCompactResponse(response.value, request, owned);
|
|
137
140
|
return new Response(response, set);
|
|
138
141
|
}
|
|
139
142
|
const handleResponse = createResponseHandler({
|
package/dist/base.d.ts
CHANGED
|
@@ -39,6 +39,10 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
39
39
|
hoc?: WrapFn<any>[];
|
|
40
40
|
setup?: GracefulHandler<any>[];
|
|
41
41
|
cleanup?: GracefulHandler<any>[];
|
|
42
|
+
cleanupEpoch?: (handler: GracefulHandler<any> | GracefulHandler<any>[]) => boolean;
|
|
43
|
+
stop?: (closeActiveConnections?: boolean, failure?: {
|
|
44
|
+
error: unknown;
|
|
45
|
+
}) => Promise<void>;
|
|
42
46
|
capability?: {
|
|
43
47
|
trace?: {
|
|
44
48
|
provider: TraceCapability;
|
|
@@ -66,7 +70,7 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
66
70
|
'~hasDynamicWS'?: boolean;
|
|
67
71
|
'~hasTrace'?: boolean;
|
|
68
72
|
'~finalizeError'?: (context: Context, error: Error) => MaybePromise<Response>;
|
|
69
|
-
'~programId': ProgramId;
|
|
73
|
+
get ['~programId'](): ProgramId;
|
|
70
74
|
'~aotFingerprint'?: AotFingerprint;
|
|
71
75
|
'~compilerSession'?: CompilerSession;
|
|
72
76
|
'~generation'?: Generation;
|
|
@@ -864,7 +868,7 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
864
868
|
* on the config and triggers a fresh build of the fetch handler).
|
|
865
869
|
*/
|
|
866
870
|
compile(): this;
|
|
867
|
-
handler(index: number, immediate?: boolean
|
|
871
|
+
handler(index: number, immediate?: boolean, route?: InternalRoute, precomputedStatic?: Response, aliases?: StaticMapAliases, table?: RouteTable): CompiledHandler;
|
|
868
872
|
['~newGeneration'](): this;
|
|
869
873
|
get fetch(): (request: Request, ...rest: any[]) => MaybePromise<Response>;
|
|
870
874
|
get handle(): (url: string | Request, options?: RequestInit) => Promise<Response>;
|
|
@@ -900,12 +904,19 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
|
|
|
900
904
|
*/
|
|
901
905
|
cleanup(handler: MaybeArray<GracefulHandler<this>>): this;
|
|
902
906
|
/**
|
|
903
|
-
* Stop the underlying server (if any),
|
|
904
|
-
*
|
|
907
|
+
* Stop the underlying server (if any), then run every `cleanup` handler.
|
|
908
|
+
* Omitted and `false` are the same graceful stop: new requests are gated,
|
|
909
|
+
* tracked WebSockets are settled and active HTTP is drained, then cleanup
|
|
910
|
+
* runs and the epoch is released. `true` force-closes the transport
|
|
911
|
+
* instead of draining it, and escalates a graceful stop already in flight.
|
|
905
912
|
*
|
|
906
|
-
*
|
|
907
|
-
*
|
|
908
|
-
*
|
|
913
|
+
* Awaiting `stop()` from inside a `setup`, `cleanup` or WebSocket lifecycle
|
|
914
|
+
* callback is only supported while that callback is still synchronous; the
|
|
915
|
+
* teardown is waiting on the callback, so after an `await` it can only be
|
|
916
|
+
* issued as `void app.stop()`.
|
|
917
|
+
*
|
|
918
|
+
* @param closeActiveConnections Pass `true` to terminate active
|
|
919
|
+
* transports. Omit (or pass `false`) to drain safely.
|
|
909
920
|
*/
|
|
910
921
|
stop(closeActiveConnections?: boolean): Promise<void> | void;
|
|
911
922
|
}
|