create-svc 0.1.43 → 0.1.45

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-svc",
3
- "version": "0.1.43",
3
+ "version": "0.1.45",
4
4
  "description": "Local microservice bootstrap CLI for Cloud Run and Workers services with Neon-backed data.",
5
5
  "module": "index.ts",
6
6
  "type": "module",
@@ -115,7 +115,7 @@ describe("buildDeploymentVerificationCommands", () => {
115
115
  });
116
116
  });
117
117
 
118
- test("uses the workers service CLI for protected workers verification", () => {
118
+ test("uses public DNS resolution for Workers production verification", () => {
119
119
  expect(
120
120
  buildDeploymentVerificationCommands({
121
121
  target: "workers",
@@ -127,7 +127,7 @@ describe("buildDeploymentVerificationCommands", () => {
127
127
  command: "sh",
128
128
  args: [
129
129
  "-c",
130
- 'TOKEN="$(service auth token)" && curl --fail --show-error --silent -H "Authorization: Bearer $TOKEN" "https://api.launch.anmho.com/v1/admin/waitlist?limit=1"',
130
+ 'TOKEN="$(service auth token)" && IP="$(dig @1.1.1.1 +short api.launch.anmho.com | head -n 1)" && test -n "$IP" && curl --fail --show-error --silent --resolve "api.launch.anmho.com:443:$IP" -H "Authorization: Bearer $TOKEN" "https://api.launch.anmho.com/v1/admin/waitlist?limit=1"',
131
131
  ],
132
132
  });
133
133
  });
@@ -98,6 +98,16 @@ export function buildDeploymentVerificationCommands(
98
98
  config: Pick<ScaffoldConfig, "apiHostname" | "framework" | "runtime"> &
99
99
  Partial<Pick<ScaffoldConfig, "target" | "serviceName" | "gcpProject" | "region">>
100
100
  ): PostScaffoldCommand[] {
101
+ if (config.target === "workers") {
102
+ const host = config.apiHostname;
103
+ const tokenCommand = 'TOKEN="$(service auth token)"';
104
+ return [
105
+ workersCurlCommand(host, "/"),
106
+ workersCurlCommand(host, "/readyz"),
107
+ workersProtectedVerificationCommand(host, tokenCommand),
108
+ ];
109
+ }
110
+
101
111
  const origin = verificationOrigin(config);
102
112
  const tokenCommand = 'TOKEN="$(service auth token)"';
103
113
  return [
@@ -107,6 +117,30 @@ export function buildDeploymentVerificationCommands(
107
117
  ];
108
118
  }
109
119
 
120
+ function workersCurlCommand(host: string, path: string): PostScaffoldCommand {
121
+ return shellVerificationCommand(workersCurlScript(host, path));
122
+ }
123
+
124
+ function workersProtectedVerificationCommand(host: string, tokenCommand: string): PostScaffoldCommand {
125
+ return shellVerificationCommand(
126
+ `${tokenCommand} && ${workersCurlScript(host, "/v1/admin/waitlist?limit=1", ['-H "Authorization: Bearer $TOKEN"'])}`
127
+ );
128
+ }
129
+
130
+ function workersCurlScript(host: string, path: string, flags: string[] = []) {
131
+ const url = `https://${host}${path}`;
132
+ return [
133
+ `IP="$(dig @1.1.1.1 +short ${host} | head -n 1)"`,
134
+ "&&",
135
+ 'test -n "$IP"',
136
+ "&&",
137
+ "curl --fail --show-error --silent",
138
+ `--resolve "${host}:443:$IP"`,
139
+ ...flags,
140
+ `"${url}"`,
141
+ ].join(" ");
142
+ }
143
+
110
144
  export function buildLocalVerificationCommands(
111
145
  config: Pick<ScaffoldConfig, "apiHostname" | "framework" | "runtime"> & Partial<Pick<ScaffoldConfig, "target">>
112
146
  ): PostScaffoldCommand[] {
@@ -316,7 +316,7 @@ test("scaffolds the workers target with wrangler lifecycle commands", async () =
316
316
  const wranglerConfig = await Bun.file(join(generatedRoot, "wrangler.toml")).text();
317
317
  expect(wranglerConfig).toContain('name = "dns-api"');
318
318
  expect(wranglerConfig).toContain('compatibility_flags = ["nodejs_compat"]');
319
- expect(wranglerConfig).toContain('pattern = "api.dns-api.anmho.com/*"');
319
+ expect(wranglerConfig).toContain('pattern = "api.dns-api.anmho.com"');
320
320
  expect(wranglerConfig).toContain('binding = "HYPERDRIVE"');
321
321
  expect(wranglerConfig).toContain('AUTH_ENABLED = "true"');
322
322
  expect(wranglerConfig).toContain('AUTH_AUDIENCE = "api://dns-api"');
@@ -452,7 +452,7 @@ async function runDoctor() {
452
452
  if (!text.includes(`name = "${config.serviceName}"`)) {
453
453
  throw new Error(`wrangler.toml does not name ${config.serviceName}`);
454
454
  }
455
- if (!text.includes(`pattern = "${config.hostname}/*"`)) {
455
+ if (!text.includes(`pattern = "${config.hostname}"`)) {
456
456
  throw new Error(`wrangler.toml does not route ${config.hostname}`);
457
457
  }
458
458
  return "name and custom domain route configured";
@@ -16,7 +16,7 @@ AUTH_JWKS_URL = "{{AUTH_JWKS_URL}}"
16
16
  crons = ["*/15 * * * *"]
17
17
 
18
18
  [[routes]]
19
- pattern = "{{API_HOSTNAME}}/*"
19
+ pattern = "{{API_HOSTNAME}}"
20
20
  custom_domain = true
21
21
 
22
22
  [[hyperdrive]]