feat: complete TASK-WP0-04 local data boundary
This commit is contained in:
@@ -34,6 +34,7 @@ import {
|
||||
type BrowserUnsupportedReason,
|
||||
} from "./browser-support.js";
|
||||
import { EventHub } from "./event-hub.js";
|
||||
import type { PublicAssetResolver } from "./local-data-root.js";
|
||||
import { isAllowedNetworkRequest, type NetworkBoundaryOptions } from "./network-boundary.js";
|
||||
|
||||
const defaultBootstrap: BootstrapResponse = {
|
||||
@@ -55,6 +56,7 @@ export interface CreateAppOptions {
|
||||
browserSupportSecret?: Buffer;
|
||||
eventHub?: EventHub;
|
||||
networkBoundary?: NetworkBoundaryOptions;
|
||||
publicAssets?: PublicAssetResolver;
|
||||
}
|
||||
|
||||
const supportGateDirectory = resolve("apps/web/support-gate");
|
||||
@@ -211,6 +213,21 @@ export async function createApp(options: CreateAppOptions = {}) {
|
||||
status: "ready",
|
||||
}));
|
||||
|
||||
app.get(
|
||||
"/api/v1/assets/public/:resourceVersion/:assetId",
|
||||
{ schema: { hide: true } },
|
||||
async (request, reply) => {
|
||||
const { assetId, resourceVersion } = request.params as { assetId?: string; resourceVersion?: string };
|
||||
const resource = assetId && resourceVersion
|
||||
? options.publicAssets?.read(resourceVersion, assetId)
|
||||
: undefined;
|
||||
if (!resource) return reply.code(404).send();
|
||||
reply.type(resource.mimeType);
|
||||
reply.header("Content-Disposition", "inline");
|
||||
return resource.bytes;
|
||||
},
|
||||
);
|
||||
|
||||
app.post(
|
||||
"/api/v1/support/check",
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user