Implement basic manifest and asset server
diff --git a/src/deployments/expo.ts b/src/deployments/expo.ts
index 739e2d3..b5d404c 100644
--- a/src/deployments/expo.ts
+++ b/src/deployments/expo.ts
@@ -5,7 +5,7 @@
import { serveR2 } from "../util/r2";
export function expoRouter(request: Request, env: Env, ctx: AeroCtx, product: string, pathname: string): Promise<Response> {
- const [, resource, key] = pathname.match(/\/(.+?)\/(.+?)(?:$|\/)/) ?? [];
+ const [, resource, key] = pathname.match(/\/(.+?)(?:$|\/(.*?)(?:$|\/))/) ?? [];
switch (resource) {
case "protocol1": return serveExpoProtocol1(request, env, ctx, product, pathname);
@@ -31,5 +31,28 @@
async function serveExpoManifest(request: Request, env: Env, ctx: AeroCtx, product: string, manifestID: string) {
if (!isSafe(manifestID)) return env.HTTP_STATUS_PAGES.fetch("https://http-status-pages.jottocraft.com/?status=400");
- return serveR2(request, env, `${product}/expo/${manifestID}.json`);
+
+ const object = await env.ARTIFACTS.get(`${product}/expo/${manifestID}.json`);
+ if (!object) return env.HTTP_STATUS_PAGES.fetch("https://http-status-pages.jottocraft.com/?status=404");
+ const buildManifest = await object.json();
+
+ const boundary = "jottocraft-Aero-Boundary-" + crypto.randomUUID();
+
+ let multipartBody = [""];
+ multipartBody.push("--" + boundary);
+ multipartBody.push("Content-Disposition: inline; name=\"manifest\"");
+ multipartBody.push("Content-Type: application/json\n");
+ multipartBody.push("");
+ multipartBody.push(JSON.stringify(buildManifest));
+
+ multipartBody.push("--" + boundary + "--");
+
+ return new Response(multipartBody.join("\r\n"), {
+ status: 200,
+ headers: {
+ "Content-Type": "multipart/mixed; boundary=" + boundary,
+ "Expo-Protocol-Version": "1",
+ "Expo-SFV-Version": "0"
+ }
+ })
}
\ No newline at end of file
diff --git a/wrangler.toml b/wrangler.toml
index e03558b..fe79826 100644
--- a/wrangler.toml
+++ b/wrangler.toml
@@ -11,7 +11,7 @@
]
kv_namespaces = [
- { binding = "CACHE", id = "61f57680d0654eb3ba0ebb94e275251c" }
+ { binding = "CACHE", id = "61f57680d0654eb3ba0ebb94e275251c", preview_id = "61f57680d0654eb3ba0ebb94e275251c" }
]
r2_buckets = [