The best way to control Claude Code, Codex and more from any computer or phone

main
ts 58 lines 1.92 KB
Raw
1 import { defineScene } from "../capture/scene.ts";
2
3 export default defineScene({
4 title: "Storage as a Layer, with Neon",
5 chapter: "06-layers-neon",
6 notes:
7 "Links is a service contract; LinksSql implements it over Effect's generic SqlClient. Each storage Layer owns its infrastructure: D1Storage declares the D1 database, NeonStorage declares a Neon Postgres project behind Hyperdrive, with the same migrations. Swapping is one Effect.provide line. Neon has no emulator, so alchemy dev creates a real Neon project in the dev stage next to the local Worker. The tests pass unchanged apart from the provider list.",
8 async run(s) {
9 await s.sync({
10 except: [
11 "src/Links.ts",
12 "src/Storage.ts",
13 "src/Api.ts",
14 "alchemy.run.ts",
15 "test/api.test.ts",
16 "src/Db.ts",
17 ],
18 });
19 await s.editor.show("src/Links.ts");
20 s.pause(1);
21 await s.editor.show("src/Storage.ts");
22 s.pause(1);
23 await s.editor.show("src/Api.ts");
24 s.pause(0.5);
25 await s.editor.remove("src/Db.ts");
26 await s.editor.show("alchemy.run.ts");
27 s.pause(1);
28
29 await s.terminal(async (t) => {
30 await t.waitDev({ timeout: 240_000 });
31 await t.sleep(800);
32 await t.run(
33 "deploy",
34 `CODE=$(curl -s --json '{"url":"https://neon.com"}' localhost:1337/links | jq -r .code)`,
35 );
36 await t.run("deploy", "curl localhost:1337/links");
37 });
38
39 await s.browser.open("http://localhost:5173", { waitFor: /neon\.com/ });
40 s.pause(1.5);
41 await s.diagram({
42 stage: `dev_${process.env.USER}`,
43 nodes: ["Postgres", "Pool"],
44 edges: ["Api->Pool", "Pool->Postgres"],
45 });
46 s.pause(1);
47
48 await s.editor.show("test/api.test.ts");
49 s.pause(0.5);
50 await s.terminal(async (t) => {
51 await t.run("test", "pnpm test", {
52 until: /Ran \d+ tests? across[\s\S]*❯\s*$/,
53 timeout: 300_000,
54 });
55 await t.sleep(1500);
56 });
57 },
58 });