burger-api 0.9.6 → 1.0.0-beta
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/README.md +84 -241
- package/dist/src/adapter/bun/index.d.ts +14 -0
- package/dist/src/adapter/bun/index.js +73 -0
- package/dist/src/adapter/bun/types.d.ts +15 -0
- package/dist/src/adapter/bun/types.js +1 -0
- package/dist/src/adapter/index.d.ts +1 -0
- package/dist/src/adapter/index.js +1 -0
- package/dist/src/adapter/types.d.ts +49 -0
- package/dist/src/adapter/types.js +1 -0
- package/dist/src/adapter/web-standard/fetch-handler.d.ts +39 -0
- package/dist/src/adapter/web-standard/fetch-handler.js +54 -0
- package/dist/src/adapter/web-standard/index.d.ts +8 -0
- package/dist/src/adapter/web-standard/index.js +7 -0
- package/dist/src/analysis/route-access-analyzer.d.ts +10 -0
- package/dist/src/analysis/route-access-analyzer.js +287 -0
- package/dist/src/chain/chain.d.ts +16 -0
- package/dist/src/chain/chain.js +17 -0
- package/dist/src/chain/flattener.d.ts +3 -0
- package/dist/src/chain/flattener.js +78 -0
- package/dist/src/chain/node.d.ts +25 -0
- package/dist/src/chain/node.js +1 -0
- package/dist/src/compiler/conventions.d.ts +67 -0
- package/dist/src/compiler/conventions.js +129 -0
- package/dist/src/compiler/index.d.ts +13 -0
- package/dist/src/compiler/index.js +11 -0
- package/dist/src/compiler/module-loader.d.ts +75 -0
- package/dist/src/compiler/module-loader.js +276 -0
- package/dist/src/compiler/route-module.d.ts +97 -0
- package/dist/src/compiler/route-module.js +1 -0
- package/dist/src/compiler/route-tree.d.ts +19 -0
- package/dist/src/compiler/route-tree.js +28 -0
- package/dist/src/compiler/scanner.d.ts +42 -0
- package/dist/src/compiler/scanner.js +201 -0
- package/dist/src/context/context-set.d.ts +26 -0
- package/dist/src/context/context-set.js +45 -0
- package/dist/src/context/context.d.ts +357 -0
- package/dist/src/context/context.js +401 -0
- package/dist/src/context/query-parser.d.ts +23 -0
- package/dist/src/context/query-parser.js +132 -0
- package/dist/src/context/route-access.d.ts +7 -0
- package/dist/src/context/route-access.js +18 -0
- package/dist/src/context/types.d.ts +62 -0
- package/dist/src/context/types.js +5 -0
- package/dist/src/core/asset-mime.d.ts +9 -0
- package/dist/src/core/asset-mime.js +35 -0
- package/dist/src/core/assets.d.ts +30 -0
- package/dist/src/core/assets.js +67 -0
- package/dist/src/core/docs-providers.d.ts +13 -0
- package/dist/src/core/docs-providers.js +89 -0
- package/dist/src/core/embedded-assets.d.ts +18 -0
- package/dist/src/core/embedded-assets.js +13 -0
- package/dist/src/core/openapi.d.ts +9 -10
- package/dist/src/core/openapi.js +333 -127
- package/dist/src/core/page-router.d.ts +13 -17
- package/dist/src/core/page-router.js +86 -55
- package/dist/src/core/server.d.ts +20 -11
- package/dist/src/core/server.js +41 -45
- package/dist/src/errors/forbidden.d.ts +14 -0
- package/dist/src/errors/forbidden.js +16 -0
- package/dist/src/errors/http-error.d.ts +47 -0
- package/dist/src/errors/http-error.js +146 -0
- package/dist/src/errors/method-not-allowed.d.ts +13 -0
- package/dist/src/errors/method-not-allowed.js +15 -0
- package/dist/src/errors/not-found.d.ts +14 -0
- package/dist/src/errors/not-found.js +16 -0
- package/dist/src/errors/unauthorized.d.ts +14 -0
- package/dist/src/errors/unauthorized.js +16 -0
- package/dist/src/index.d.ts +263 -50
- package/dist/src/index.js +919 -332
- package/dist/src/lifecycle/executor.d.ts +64 -0
- package/dist/src/lifecycle/executor.js +201 -0
- package/dist/src/lifecycle/hook-runner.d.ts +11 -0
- package/dist/src/lifecycle/hook-runner.js +156 -0
- package/dist/src/lifecycle/jit.d.ts +50 -0
- package/dist/src/lifecycle/jit.js +258 -0
- package/dist/src/lifecycle/transform.d.ts +26 -0
- package/dist/src/lifecycle/transform.js +99 -0
- package/dist/src/lifecycle/types.d.ts +135 -0
- package/dist/src/lifecycle/types.js +1 -0
- package/dist/src/plugin/composer.d.ts +3 -0
- package/dist/src/plugin/composer.js +28 -0
- package/dist/src/plugin/registry.d.ts +25 -0
- package/dist/src/plugin/registry.js +107 -0
- package/dist/src/plugin/types.d.ts +20 -0
- package/dist/src/plugin/types.js +1 -0
- package/dist/src/router/allow-cache.d.ts +20 -0
- package/dist/src/router/allow-cache.js +26 -0
- package/dist/src/router/compiler.d.ts +39 -0
- package/dist/src/router/compiler.js +817 -0
- package/dist/src/router/define.d.ts +67 -0
- package/dist/src/router/define.js +34 -0
- package/dist/src/router/index.d.ts +6 -0
- package/dist/src/router/index.js +5 -0
- package/dist/src/router/param-extract.d.ts +33 -0
- package/dist/src/router/param-extract.js +87 -0
- package/dist/src/router/regex-matcher.d.ts +42 -0
- package/dist/src/router/regex-matcher.js +216 -0
- package/dist/src/router/router.d.ts +201 -0
- package/dist/src/router/router.js +600 -0
- package/dist/src/router/static-map.d.ts +39 -0
- package/dist/src/router/static-map.js +48 -0
- package/dist/src/router/trie.d.ts +69 -0
- package/dist/src/router/trie.js +572 -0
- package/dist/src/router/types.d.ts +104 -0
- package/dist/src/router/types.js +1 -0
- package/dist/src/runtime/capabilities.d.ts +29 -0
- package/dist/src/runtime/capabilities.js +48 -0
- package/dist/src/types/index.d.ts +260 -109
- package/dist/src/types/index.js +1 -1
- package/dist/src/types/inference.d.ts +78 -0
- package/dist/src/types/inference.js +20 -0
- package/dist/src/types/openapi-config.d.ts +164 -0
- package/dist/src/types/openapi-config.js +8 -0
- package/dist/src/utils/env.d.ts +13 -0
- package/dist/src/utils/env.js +24 -0
- package/dist/src/utils/fs.d.ts +29 -0
- package/dist/src/utils/fs.js +75 -0
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/src/utils/index.js +2 -2
- package/dist/src/utils/pathConversion.js +13 -7
- package/dist/src/utils/response.d.ts +42 -6
- package/dist/src/utils/response.js +172 -7
- package/dist/src/utils/routing.d.ts +32 -13
- package/dist/src/utils/routing.js +41 -18
- package/dist/src/utils/thenable.d.ts +8 -0
- package/dist/src/utils/thenable.js +12 -0
- package/dist/src/utils/timing-safe.d.ts +9 -0
- package/dist/src/utils/timing-safe.js +20 -0
- package/dist/src/utils/wildcard.d.ts +2 -9
- package/dist/src/utils/wildcard.js +20 -58
- package/dist/src/validation/adapter.d.ts +54 -0
- package/dist/src/validation/adapter.js +75 -0
- package/dist/src/validation/adapters/standard.d.ts +11 -0
- package/dist/src/validation/adapters/standard.js +110 -0
- package/dist/src/validation/adapters/zod.d.ts +9 -0
- package/dist/src/validation/adapters/zod.js +128 -0
- package/dist/src/validation/cache.d.ts +26 -0
- package/dist/src/validation/cache.js +35 -0
- package/dist/src/validation/coerce.d.ts +28 -0
- package/dist/src/validation/coerce.js +176 -0
- package/dist/src/validation/compiler.d.ts +27 -0
- package/dist/src/validation/compiler.js +191 -0
- package/dist/src/validation/error.d.ts +69 -0
- package/dist/src/validation/error.js +137 -0
- package/dist/src/validation/index.d.ts +16 -0
- package/dist/src/validation/index.js +12 -0
- package/dist/src/validation/response.d.ts +25 -0
- package/dist/src/validation/response.js +79 -0
- package/dist/src/validation/types.d.ts +148 -0
- package/dist/src/validation/types.js +6 -0
- package/dist/src/validation/validator.d.ts +39 -0
- package/dist/src/validation/validator.js +441 -0
- package/dist/src/ws/adapter.d.ts +219 -0
- package/dist/src/ws/adapter.js +623 -0
- package/dist/src/ws/compiler.d.ts +37 -0
- package/dist/src/ws/compiler.js +156 -0
- package/dist/src/ws/index.d.ts +11 -0
- package/dist/src/ws/index.js +8 -0
- package/dist/src/ws/platform.d.ts +81 -0
- package/dist/src/ws/platform.js +113 -0
- package/dist/src/ws/router.d.ts +48 -0
- package/dist/src/ws/router.js +174 -0
- package/dist/src/ws/scanner.d.ts +97 -0
- package/dist/src/ws/scanner.js +193 -0
- package/dist/src/ws/types.d.ts +380 -0
- package/dist/src/ws/types.js +213 -0
- package/package.json +72 -59
- package/dist/src/core/api-router.d.ts +0 -65
- package/dist/src/core/api-router.js +0 -264
- package/dist/src/core/swagger-ui.d.ts +0 -1
- package/dist/src/core/swagger-ui.js +0 -33
- package/dist/src/middleware/validator.d.ts +0 -14
- package/dist/src/middleware/validator.js +0 -133
- package/dist/src/utils/error.d.ts +0 -17
- package/dist/src/utils/error.js +0 -63
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extension → Content-Type lookup for static assets. Kept separate from
|
|
3
|
+
* `assets.ts` so the main entry can re-export `contentTypeFor` without pulling
|
|
4
|
+
* a Node builtin into its static import graph.
|
|
5
|
+
*/
|
|
6
|
+
/** Extension → Content-Type map for supported static assets. */
|
|
7
|
+
export const ASSET_MIME = {
|
|
8
|
+
css: 'text/css; charset=utf-8',
|
|
9
|
+
js: 'text/javascript; charset=utf-8',
|
|
10
|
+
mjs: 'text/javascript; charset=utf-8',
|
|
11
|
+
svg: 'image/svg+xml',
|
|
12
|
+
png: 'image/png',
|
|
13
|
+
jpg: 'image/jpeg',
|
|
14
|
+
jpeg: 'image/jpeg',
|
|
15
|
+
gif: 'image/gif',
|
|
16
|
+
webp: 'image/webp',
|
|
17
|
+
ico: 'image/x-icon',
|
|
18
|
+
json: 'application/json; charset=utf-8',
|
|
19
|
+
txt: 'text/plain; charset=utf-8',
|
|
20
|
+
html: 'text/html; charset=utf-8',
|
|
21
|
+
woff: 'font/woff',
|
|
22
|
+
woff2: 'font/woff2',
|
|
23
|
+
ttf: 'font/ttf',
|
|
24
|
+
otf: 'font/otf',
|
|
25
|
+
mp3: 'audio/mpeg',
|
|
26
|
+
mp4: 'video/mp4',
|
|
27
|
+
webm: 'video/webm',
|
|
28
|
+
pdf: 'application/pdf',
|
|
29
|
+
wasm: 'application/wasm',
|
|
30
|
+
};
|
|
31
|
+
/** Resolves the content type for an asset path (defaults to octet-stream). */
|
|
32
|
+
export function contentTypeFor(filePath) {
|
|
33
|
+
const ext = filePath.slice(filePath.lastIndexOf('.') + 1).toLowerCase();
|
|
34
|
+
return ASSET_MIME[ext] ?? 'application/octet-stream';
|
|
35
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static asset serving for pages. Assets live under `<pageDir>/assets/` and
|
|
3
|
+
* are served at `{pagePrefix}/assets/<relative-path>`.
|
|
4
|
+
*
|
|
5
|
+
* Dev (`pageDir` set) reads files from disk per request; production AOT
|
|
6
|
+
* (`assetRoutes` from the CLI build) embeds base64 contents in the bundle.
|
|
7
|
+
*/
|
|
8
|
+
import type { RequestHandler } from '../types/index.js';
|
|
9
|
+
export { ASSET_MIME, contentTypeFor } from './asset-mime.js';
|
|
10
|
+
/** A single static asset resolved from disk (dev mode). */
|
|
11
|
+
export interface DiskAssetRoute {
|
|
12
|
+
/** Route path including the prefix (e.g. `/assets/style.css`). */
|
|
13
|
+
routePath: string;
|
|
14
|
+
/** Absolute file path on disk. */
|
|
15
|
+
file: string;
|
|
16
|
+
contentType: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Recursively collects one route entry per file under `<pageDir>/assets/`;
|
|
20
|
+
* returns `[]` when the directory does not exist.
|
|
21
|
+
*/
|
|
22
|
+
export declare function collectDiskAssetRoutes(pageDir: string, prefix?: string): Promise<DiskAssetRoute[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Handler for a disk-backed asset: streams the file via `Bun.file` per request
|
|
25
|
+
* so dev edits show without a restart. Fails loud when Bun is unavailable
|
|
26
|
+
* instead of a bare "Bun is not defined".
|
|
27
|
+
*/
|
|
28
|
+
export declare function diskAssetHandler(route: DiskAssetRoute): RequestHandler;
|
|
29
|
+
export { embeddedAssetHandler } from './embedded-assets.js';
|
|
30
|
+
export type { EmbeddedAsset } from './embedded-assets.js';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static asset serving for pages. Assets live under `<pageDir>/assets/` and
|
|
3
|
+
* are served at `{pagePrefix}/assets/<relative-path>`.
|
|
4
|
+
*
|
|
5
|
+
* Dev (`pageDir` set) reads files from disk per request; production AOT
|
|
6
|
+
* (`assetRoutes` from the CLI build) embeds base64 contents in the bundle.
|
|
7
|
+
*/
|
|
8
|
+
import { readdir } from 'node:fs/promises';
|
|
9
|
+
import * as path from 'node:path';
|
|
10
|
+
import { contentTypeFor } from './asset-mime.js';
|
|
11
|
+
export { ASSET_MIME, contentTypeFor } from './asset-mime.js';
|
|
12
|
+
/**
|
|
13
|
+
* Recursively collects one route entry per file under `<pageDir>/assets/`;
|
|
14
|
+
* returns `[]` when the directory does not exist.
|
|
15
|
+
*/
|
|
16
|
+
export async function collectDiskAssetRoutes(pageDir, prefix = '') {
|
|
17
|
+
const assetsDir = path.resolve(pageDir, 'assets');
|
|
18
|
+
let entries;
|
|
19
|
+
try {
|
|
20
|
+
entries = (await readdir(assetsDir, {
|
|
21
|
+
withFileTypes: true,
|
|
22
|
+
recursive: true,
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
const cleanPrefix = prefix.replace(/\/+$/, '');
|
|
29
|
+
const routes = [];
|
|
30
|
+
for (const entry of entries) {
|
|
31
|
+
if (!entry.isFile())
|
|
32
|
+
continue;
|
|
33
|
+
// `parentPath` carries the subdirectory path for nested files.
|
|
34
|
+
const parent = entry.parentPath ?? '';
|
|
35
|
+
const relative = path.relative(assetsDir, path.join(parent, entry.name));
|
|
36
|
+
const normalized = relative.split(path.sep).join('/');
|
|
37
|
+
routes.push({
|
|
38
|
+
routePath: `${cleanPrefix}/assets/${normalized}`,
|
|
39
|
+
file: path.join(assetsDir, relative),
|
|
40
|
+
contentType: contentTypeFor(entry.name),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return routes.sort((a, b) => a.routePath.localeCompare(b.routePath));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Handler for a disk-backed asset: streams the file via `Bun.file` per request
|
|
47
|
+
* so dev edits show without a restart. Fails loud when Bun is unavailable
|
|
48
|
+
* instead of a bare "Bun is not defined".
|
|
49
|
+
*/
|
|
50
|
+
export function diskAssetHandler(route) {
|
|
51
|
+
return async () => {
|
|
52
|
+
if (typeof Bun === 'undefined') {
|
|
53
|
+
throw new Error(`[burger-api] Disk-backed asset serving ("${route.routePath}") ` +
|
|
54
|
+
'requires Bun. Use `burger-api build` to embed assets ' +
|
|
55
|
+
'for other runtimes — see EmbeddedAsset / embeddedAssetHandler.');
|
|
56
|
+
}
|
|
57
|
+
const file = Bun.file(route.file);
|
|
58
|
+
if (!(await file.exists())) {
|
|
59
|
+
return new Response('Asset not found', { status: 404 });
|
|
60
|
+
}
|
|
61
|
+
return new Response(file, {
|
|
62
|
+
headers: { 'Content-Type': route.contentType },
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
// Embedded assets live in a module without `node:fs` (portable bundles).
|
|
67
|
+
export { embeddedAssetHandler } from './embedded-assets.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DocsProvider } from '../types/openapi-config.js';
|
|
2
|
+
/**
|
|
3
|
+
* Scalar API Reference docs UI, loaded from a CDN.
|
|
4
|
+
*/
|
|
5
|
+
export declare function scalarDocs(): DocsProvider;
|
|
6
|
+
/**
|
|
7
|
+
* Swagger UI (default docs UI), loaded from a CDN.
|
|
8
|
+
*/
|
|
9
|
+
export declare function swaggerDocs(): DocsProvider;
|
|
10
|
+
/**
|
|
11
|
+
* ReDoc docs UI, loaded from a CDN.
|
|
12
|
+
*/
|
|
13
|
+
export declare function redocDocs(): DocsProvider;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** Escapes text for safe interpolation into HTML content and attributes. */
|
|
2
|
+
function escapeHtml(value) {
|
|
3
|
+
return value
|
|
4
|
+
.replace(/&/g, '&')
|
|
5
|
+
.replace(/</g, '<')
|
|
6
|
+
.replace(/>/g, '>')
|
|
7
|
+
.replace(/"/g, '"')
|
|
8
|
+
.replace(/'/g, ''');
|
|
9
|
+
}
|
|
10
|
+
function pageTitle(spec) {
|
|
11
|
+
const title = spec.info?.title;
|
|
12
|
+
return escapeHtml(typeof title === 'string' && title ? title : 'API Documentation');
|
|
13
|
+
}
|
|
14
|
+
/** A JS string literal safe to embed inside an inline <script>. */
|
|
15
|
+
function jsString(value) {
|
|
16
|
+
return JSON.stringify(value).replace(/</g, '\\u003c');
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Scalar API Reference docs UI, loaded from a CDN.
|
|
20
|
+
*/
|
|
21
|
+
export function scalarDocs() {
|
|
22
|
+
return (spec, { specUrl }) => `<!DOCTYPE html>
|
|
23
|
+
<html lang="en">
|
|
24
|
+
<head>
|
|
25
|
+
<meta charset="UTF-8">
|
|
26
|
+
<title>${pageTitle(spec)}</title>
|
|
27
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
<script id="api-reference" data-url="${escapeHtml(specUrl)}"></script>
|
|
31
|
+
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
|
|
32
|
+
</body>
|
|
33
|
+
</html>`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Swagger UI (default docs UI), loaded from a CDN.
|
|
37
|
+
*/
|
|
38
|
+
export function swaggerDocs() {
|
|
39
|
+
return (spec, { specUrl }) => `<!DOCTYPE html>
|
|
40
|
+
<html lang="en">
|
|
41
|
+
<head>
|
|
42
|
+
<meta charset="UTF-8">
|
|
43
|
+
<title>${pageTitle(spec)}</title>
|
|
44
|
+
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist/swagger-ui.css" />
|
|
45
|
+
<style>
|
|
46
|
+
body { margin: 0; padding: 0; }
|
|
47
|
+
</style>
|
|
48
|
+
</head>
|
|
49
|
+
<body>
|
|
50
|
+
<div id="swagger-ui"></div>
|
|
51
|
+
<script src="https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js"></script>
|
|
52
|
+
<script>
|
|
53
|
+
window.onload = function() {
|
|
54
|
+
SwaggerUIBundle({
|
|
55
|
+
url: ${jsString(specUrl)},
|
|
56
|
+
dom_id: '#swagger-ui',
|
|
57
|
+
presets: [
|
|
58
|
+
SwaggerUIBundle.presets.apis,
|
|
59
|
+
SwaggerUIBundle.SwaggerUIStandalonePreset
|
|
60
|
+
],
|
|
61
|
+
layout: "BaseLayout",
|
|
62
|
+
docExpansion: "none",
|
|
63
|
+
filter: true,
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
</script>
|
|
67
|
+
</body>
|
|
68
|
+
</html>`;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* ReDoc docs UI, loaded from a CDN.
|
|
72
|
+
*/
|
|
73
|
+
export function redocDocs() {
|
|
74
|
+
return (spec, { specUrl }) => `<!DOCTYPE html>
|
|
75
|
+
<html lang="en">
|
|
76
|
+
<head>
|
|
77
|
+
<meta charset="UTF-8">
|
|
78
|
+
<title>${pageTitle(spec)}</title>
|
|
79
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
80
|
+
</head>
|
|
81
|
+
<body>
|
|
82
|
+
<div id="redoc"></div>
|
|
83
|
+
<script src="https://cdn.jsdelivr.net/npm/redoc/bundles/redoc.standalone.js"></script>
|
|
84
|
+
<script>
|
|
85
|
+
Redoc.init(${jsString(specUrl)}, {}, document.getElementById('redoc'));
|
|
86
|
+
</script>
|
|
87
|
+
</body>
|
|
88
|
+
</html>`;
|
|
89
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RequestHandler } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Embedded (base64) static assets for production AOT builds. Kept apart from
|
|
4
|
+
* `assets.ts` so portable bundles (`toFetchHandler`) never load `node:fs`.
|
|
5
|
+
*/
|
|
6
|
+
/** A static asset with its contents base64-embedded (production AOT). */
|
|
7
|
+
export interface EmbeddedAsset {
|
|
8
|
+
/** Route path including the prefix (e.g. `/assets/style.css`). */
|
|
9
|
+
path: string;
|
|
10
|
+
contentType: string;
|
|
11
|
+
/** File contents encoded as standard base64. */
|
|
12
|
+
data: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Handler for an embedded asset: decodes the base64 payload once with the
|
|
16
|
+
* Web-standard `atob` and serves the bytes.
|
|
17
|
+
*/
|
|
18
|
+
export declare function embeddedAssetHandler(asset: EmbeddedAsset): RequestHandler;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handler for an embedded asset: decodes the base64 payload once with the
|
|
3
|
+
* Web-standard `atob` and serves the bytes.
|
|
4
|
+
*/
|
|
5
|
+
export function embeddedAssetHandler(asset) {
|
|
6
|
+
const binary = atob(asset.data);
|
|
7
|
+
const bytes = new Uint8Array(binary.length);
|
|
8
|
+
for (let i = 0; i < binary.length; i++)
|
|
9
|
+
bytes[i] = binary.charCodeAt(i);
|
|
10
|
+
return () => new Response(bytes, {
|
|
11
|
+
headers: { 'Content-Type': asset.contentType },
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { ServerOptions, RouteDefinition } from '../types/index';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
1
|
+
import type { ServerOptions, RouteDefinition, OpenAPIConfig, OpenAPIObject } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generates a full OpenAPI 3.1 document from API routes.
|
|
4
|
+
*
|
|
5
|
+
* @param apiRoutes Compiled route definitions.
|
|
6
|
+
* @param options Server options (fallback metadata source).
|
|
7
|
+
* @param config OpenAPI config from `openapi.config.ts` (primary metadata source).
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateOpenAPIDocument(apiRoutes: RouteDefinition[], options: ServerOptions, config?: OpenAPIConfig): OpenAPIObject;
|