create-svc 0.1.10 → 0.1.11
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 +46 -43
- package/bin/create-service.mjs +2 -0
- package/package.json +12 -9
- package/src/cli.test.ts +28 -10
- package/src/cli.ts +195 -30
- package/src/git-bootstrap.test.ts +40 -0
- package/src/git-bootstrap.ts +110 -0
- package/src/naming.test.ts +1 -0
- package/src/naming.ts +23 -0
- package/src/post-scaffold.test.ts +19 -0
- package/src/post-scaffold.ts +17 -4
- package/src/profiles.ts +2 -5
- package/src/scaffold.test.ts +231 -40
- package/src/scaffold.ts +84 -29
- package/src/vault.test.ts +61 -1
- package/src/vault.ts +77 -15
- package/templates/shared/.github/workflows/ci.yml +2 -1
- package/templates/shared/.github/workflows/deploy.yml +2 -0
- package/templates/shared/README.md +124 -47
- package/templates/shared/grafana/alerts.yaml +54 -0
- package/templates/shared/grafana/waitlist-dashboard.json +63 -0
- package/templates/shared/scripts/authctl.ts +231 -0
- package/templates/shared/scripts/cloudrun/bootstrap.ts +14 -5
- package/templates/shared/scripts/cloudrun/cleanup.ts +64 -4
- package/templates/shared/scripts/cloudrun/cli.ts +324 -7
- package/templates/shared/scripts/cloudrun/config.ts +11 -4
- package/templates/shared/scripts/cloudrun/deploy.ts +0 -4
- package/templates/shared/scripts/cloudrun/lib.ts +174 -41
- package/templates/shared/scripts/cloudrun/neon.ts +45 -0
- package/templates/shared/scripts/dev.ts +22 -0
- package/templates/shared/scripts/ensure-local-db.ts +3 -0
- package/templates/shared/scripts/local-docker.ts +63 -0
- package/templates/shared/scripts/local-env.ts +27 -0
- package/templates/shared/scripts/seed.ts +73 -0
- package/templates/shared/scripts/wait-for-db.ts +32 -0
- package/templates/shared/service.config.ts +59 -0
- package/templates/shared/service.yaml +24 -44
- package/templates/targets/workers/.github/workflows/ci.yml +19 -0
- package/templates/targets/workers/.github/workflows/deploy.yml +19 -0
- package/templates/targets/workers/Makefile +33 -0
- package/templates/targets/workers/README.md +75 -0
- package/templates/targets/workers/package.json +35 -0
- package/templates/targets/workers/scripts/workers/cli.ts +397 -0
- package/templates/targets/workers/src/auth.ts +178 -0
- package/templates/targets/workers/src/index.ts +198 -0
- package/templates/targets/workers/src/storage.ts +370 -0
- package/templates/targets/workers/test/app.test.ts +108 -0
- package/templates/targets/workers/tsconfig.json +11 -0
- package/templates/targets/workers/wrangler.toml +24 -0
- package/templates/variants/bun-connectrpc/Makefile +14 -8
- package/templates/variants/bun-connectrpc/gen/protos/waitlist/v1/waitlist_pb.ts +424 -0
- package/templates/variants/bun-connectrpc/migrations/0000_init.sql +12 -55
- package/templates/variants/bun-connectrpc/package.json +12 -5
- package/templates/variants/bun-connectrpc/protos/waitlist/v1/waitlist.proto +91 -0
- package/templates/variants/bun-connectrpc/scripts/codegen.ts +1 -1
- package/templates/variants/bun-connectrpc/scripts/migrate.ts +4 -1
- package/templates/variants/bun-connectrpc/src/auth.ts +200 -0
- package/templates/variants/bun-connectrpc/src/db/repository.ts +67 -420
- package/templates/variants/bun-connectrpc/src/db/schema.ts +15 -64
- package/templates/variants/bun-connectrpc/src/index.ts +76 -176
- package/templates/variants/bun-connectrpc/src/temporal/activities.ts +14 -0
- package/templates/variants/bun-connectrpc/src/temporal/worker.ts +38 -0
- package/templates/variants/bun-connectrpc/src/temporal/workflows.ts +10 -0
- package/templates/variants/bun-connectrpc/src/waitlist/service.ts +172 -0
- package/templates/variants/bun-connectrpc/src/waitlist/types.ts +45 -0
- package/templates/variants/bun-connectrpc/test/app.test.ts +4 -4
- package/templates/variants/bun-connectrpc/test/waitlist.integration.test.ts +71 -0
- package/templates/variants/bun-hono/Makefile +14 -8
- package/templates/variants/bun-hono/migrations/0000_init.sql +12 -55
- package/templates/variants/bun-hono/package.json +12 -5
- package/templates/variants/bun-hono/scripts/migrate.ts +4 -1
- package/templates/variants/bun-hono/src/auth.ts +181 -0
- package/templates/variants/bun-hono/src/db/repository.ts +68 -421
- package/templates/variants/bun-hono/src/db/schema.ts +15 -64
- package/templates/variants/bun-hono/src/index.ts +65 -180
- package/templates/variants/bun-hono/src/temporal/activities.ts +14 -0
- package/templates/variants/bun-hono/src/temporal/worker.ts +38 -0
- package/templates/variants/bun-hono/src/temporal/workflows.ts +10 -0
- package/templates/variants/bun-hono/src/waitlist/service.ts +166 -0
- package/templates/variants/bun-hono/src/waitlist/types.ts +50 -0
- package/templates/variants/bun-hono/test/app.test.ts +72 -41
- package/templates/variants/bun-hono/test/waitlist.integration.test.ts +102 -0
- package/templates/variants/go-chi/Makefile +27 -11
- package/templates/variants/go-chi/atlas.hcl +8 -0
- package/templates/variants/go-chi/cmd/server/main.go +21 -10
- package/templates/variants/go-chi/go.mod +1 -3
- package/templates/variants/go-chi/internal/app/service.go +202 -685
- package/templates/variants/go-chi/internal/auth/middleware.go +289 -0
- package/templates/variants/go-chi/internal/auth/middleware_test.go +38 -0
- package/templates/variants/go-chi/internal/config/config.go +27 -11
- package/templates/variants/go-chi/internal/httpapi/routes.go +78 -157
- package/templates/variants/go-chi/internal/httpapi/waitlist_integration_test.go +199 -0
- package/templates/variants/go-chi/internal/temporal/activities.go +27 -0
- package/templates/variants/go-chi/internal/temporal/worker.go +42 -0
- package/templates/variants/go-chi/internal/temporal/workflows.go +18 -0
- package/templates/variants/go-chi/migrations/0000_init.sql +12 -55
- package/templates/variants/go-chi/migrations/atlas.sum +2 -0
- package/templates/variants/go-chi/package.json +7 -1
- package/templates/variants/go-connectrpc/Makefile +26 -9
- package/templates/variants/go-connectrpc/atlas.hcl +8 -0
- package/templates/variants/go-connectrpc/buf.gen.yaml +2 -2
- package/templates/variants/go-connectrpc/cmd/server/main.go +23 -12
- package/templates/variants/go-connectrpc/gen/waitlist/v1/waitlist.pb.go +960 -0
- package/templates/variants/go-connectrpc/gen/waitlist/v1/waitlistv1connect/waitlist.connect.go +283 -0
- package/templates/variants/go-connectrpc/go.mod +1 -1
- package/templates/variants/go-connectrpc/internal/app/service.go +202 -685
- package/templates/variants/go-connectrpc/internal/auth/middleware.go +289 -0
- package/templates/variants/go-connectrpc/internal/auth/middleware_test.go +38 -0
- package/templates/variants/go-connectrpc/internal/config/config.go +27 -11
- package/templates/variants/go-connectrpc/internal/connectapi/handler.go +78 -201
- package/templates/variants/go-connectrpc/internal/connectapi/waitlist_integration_test.go +122 -0
- package/templates/variants/go-connectrpc/internal/httpapi/routes.go +147 -9
- package/templates/variants/go-connectrpc/internal/temporal/activities.go +27 -0
- package/templates/variants/go-connectrpc/internal/temporal/worker.go +42 -0
- package/templates/variants/go-connectrpc/internal/temporal/workflows.go +18 -0
- package/templates/variants/go-connectrpc/migrations/0000_init.sql +12 -55
- package/templates/variants/go-connectrpc/migrations/atlas.sum +2 -0
- package/templates/variants/go-connectrpc/package.json +7 -1
- package/templates/variants/go-connectrpc/protos/waitlist/v1/waitlist.proto +93 -0
- package/templates/root/.github/workflows/buf-publish.yml +0 -19
- package/templates/root/.github/workflows/ci.yml +0 -26
- package/templates/root/.github/workflows/deploy.yml +0 -22
- package/templates/root/Dockerfile +0 -23
- package/templates/root/README.md +0 -69
- package/templates/root/buf.gen.yaml +0 -10
- package/templates/root/buf.yaml +0 -9
- package/templates/root/cmd/server/main.go +0 -44
- package/templates/root/gen/dns/v1/dns.pb.go +0 -623
- package/templates/root/gen/dns/v1/dnsv1connect/dns.connect.go +0 -192
- package/templates/root/go.mod +0 -10
- package/templates/root/internal/app/service.go +0 -152
- package/templates/root/internal/app/token_source.go +0 -50
- package/templates/root/internal/cloudflare/client.go +0 -160
- package/templates/root/internal/config/config.go +0 -55
- package/templates/root/internal/connectapi/handler.go +0 -79
- package/templates/root/internal/httpapi/routes.go +0 -93
- package/templates/root/internal/vault/client.go +0 -148
- package/templates/root/package.json +0 -12
- package/templates/root/protos/dns/v1/dns.proto +0 -58
- package/templates/root/scripts/cloudrun/bootstrap.ts +0 -65
- package/templates/root/scripts/cloudrun/config.ts +0 -50
- package/templates/root/scripts/cloudrun/deploy.ts +0 -41
- package/templates/root/scripts/cloudrun/lib.ts +0 -244
- package/templates/root/service.yaml +0 -50
- package/templates/root/test/go.test.ts +0 -19
- package/templates/shared/scripts/cloudrun/integrations.ts +0 -111
- package/templates/variants/bun-connectrpc/gen/protos/chat/v1/chat_pb.ts +0 -1078
- package/templates/variants/bun-connectrpc/protos/chat/v1/chat.proto +0 -228
- package/templates/variants/bun-connectrpc/src/chat/service.ts +0 -384
- package/templates/variants/bun-connectrpc/src/chat/types.ts +0 -142
- package/templates/variants/bun-connectrpc/src/storage.ts +0 -72
- package/templates/variants/bun-connectrpc/src/webhooks.ts +0 -35
- package/templates/variants/bun-connectrpc/test/list-messages.integration.test.ts +0 -182
- package/templates/variants/bun-hono/src/chat/service.ts +0 -384
- package/templates/variants/bun-hono/src/chat/types.ts +0 -142
- package/templates/variants/bun-hono/src/storage.ts +0 -72
- package/templates/variants/bun-hono/src/webhooks.ts +0 -35
- package/templates/variants/bun-hono/test/list-messages.integration.test.ts +0 -256
- package/templates/variants/go-chi/buf.gen.yaml +0 -12
- package/templates/variants/go-chi/buf.yaml +0 -9
- package/templates/variants/go-chi/cmd/migrate/main.go +0 -101
- package/templates/variants/go-chi/internal/httpapi/list_messages_integration_test.go +0 -298
- package/templates/variants/go-chi/protos/chat/v1/chat.proto +0 -219
- package/templates/variants/go-connectrpc/cmd/migrate/main.go +0 -101
- package/templates/variants/go-connectrpc/gen/chat/v1/chat.pb.go +0 -2512
- package/templates/variants/go-connectrpc/gen/chat/v1/chatv1connect/chat.connect.go +0 -571
- package/templates/variants/go-connectrpc/internal/connectapi/list_messages_integration_test.go +0 -216
- package/templates/variants/go-connectrpc/protos/chat/v1/chat.proto +0 -232
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
service_id: "{{SERVICE_ID}}",
|
|
3
|
+
target: "{{TARGET}}",
|
|
4
|
+
runtime: "{{RUNTIME}}",
|
|
5
|
+
framework: "{{FRAMEWORK}}",
|
|
6
|
+
stage_default: "prod",
|
|
7
|
+
dns: {
|
|
8
|
+
hostname: "{{API_HOSTNAME}}",
|
|
9
|
+
base_domain: "{{API_BASE_DOMAIN}}",
|
|
10
|
+
},
|
|
11
|
+
ownership: {
|
|
12
|
+
managed_by: "create-service",
|
|
13
|
+
service_id: "{{SERVICE_ID}}",
|
|
14
|
+
},
|
|
15
|
+
auth: {
|
|
16
|
+
issuer: "{{AUTH_ISSUER}}",
|
|
17
|
+
token_endpoint: "https://auth.anmho.com/api/auth/oauth2/token",
|
|
18
|
+
jwks_url: "https://auth.anmho.com/api/auth/jwks",
|
|
19
|
+
resource_server: {
|
|
20
|
+
id: "{{SERVICE_ID}}",
|
|
21
|
+
audience: "api://{{SERVICE_ID}}",
|
|
22
|
+
default_scopes: ["{{SERVICE_ID}}:read", "{{SERVICE_ID}}:write"],
|
|
23
|
+
},
|
|
24
|
+
client: {
|
|
25
|
+
app_id: "{{SERVICE_ID}}",
|
|
26
|
+
identity: "server",
|
|
27
|
+
vault_path_prefix: "prod/apps/{{SERVICE_ID}}/server/oauth-clients",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
temporal: {
|
|
31
|
+
enabled: false,
|
|
32
|
+
address: "localhost:7233",
|
|
33
|
+
namespace: "default",
|
|
34
|
+
task_queue: "{{SERVICE_ID}}",
|
|
35
|
+
api_key_secret_name: "{{SERVICE_ID}}-temporal-api-key",
|
|
36
|
+
},
|
|
37
|
+
providers: {
|
|
38
|
+
vault: {
|
|
39
|
+
mount: "secret",
|
|
40
|
+
neon_path: "prod/providers/neon",
|
|
41
|
+
grafana_path: "prod/providers/grafana",
|
|
42
|
+
clerk_m2m_path: "prod/providers/clerk-m2m",
|
|
43
|
+
temporal_path: "prod/providers/temporal",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
buf: {
|
|
47
|
+
module: "buf.build/anmho/{{SERVICE_ID}}",
|
|
48
|
+
},
|
|
49
|
+
cloudrun: {
|
|
50
|
+
project_id: "{{PROJECT_ID}}",
|
|
51
|
+
region: "{{REGION}}",
|
|
52
|
+
service_account: "{{RUNTIME_SERVICE_ACCOUNT}}",
|
|
53
|
+
},
|
|
54
|
+
workers: {
|
|
55
|
+
script_name: "{{SERVICE_ID}}",
|
|
56
|
+
hyperdrive_binding: "HYPERDRIVE",
|
|
57
|
+
cron: "*/15 * * * *",
|
|
58
|
+
},
|
|
59
|
+
} as const;
|
|
@@ -2,10 +2,17 @@ apiVersion: serving.knative.dev/v1
|
|
|
2
2
|
kind: Service
|
|
3
3
|
metadata:
|
|
4
4
|
name: ${SERVICE_NAME}
|
|
5
|
+
labels:
|
|
6
|
+
managed_by: create-service
|
|
7
|
+
service_id: ${SERVICE_ID}
|
|
5
8
|
annotations:
|
|
6
9
|
run.googleapis.com/ingress: all
|
|
7
10
|
spec:
|
|
8
11
|
template:
|
|
12
|
+
metadata:
|
|
13
|
+
labels:
|
|
14
|
+
managed_by: create-service
|
|
15
|
+
service_id: ${SERVICE_ID}
|
|
9
16
|
spec:
|
|
10
17
|
serviceAccountName: ${RUNTIME_SERVICE_ACCOUNT}
|
|
11
18
|
containers:
|
|
@@ -17,55 +24,28 @@ spec:
|
|
|
17
24
|
value: ${SERVICE_RUNTIME}
|
|
18
25
|
- name: APP_FRAMEWORK
|
|
19
26
|
value: ${SERVICE_FRAMEWORK}
|
|
27
|
+
- name: TEMPORAL_ENABLED
|
|
28
|
+
value: "${TEMPORAL_ENABLED}"
|
|
29
|
+
- name: TEMPORAL_ADDRESS
|
|
30
|
+
value: "${TEMPORAL_ADDRESS}"
|
|
31
|
+
- name: TEMPORAL_NAMESPACE
|
|
32
|
+
value: "${TEMPORAL_NAMESPACE}"
|
|
33
|
+
- name: TEMPORAL_TASK_QUEUE
|
|
34
|
+
value: "${TEMPORAL_TASK_QUEUE}"
|
|
35
|
+
${TEMPORAL_API_KEY_ENV}
|
|
20
36
|
- name: DATABASE_URL
|
|
21
37
|
valueFrom:
|
|
22
38
|
secretKeyRef:
|
|
23
39
|
name: ${DATABASE_URL_SECRET}
|
|
24
40
|
key: latest
|
|
25
|
-
- name:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
name: ${CLERK_WEBHOOK_SECRET}
|
|
34
|
-
key: latest
|
|
35
|
-
- name: STRIPE_SECRET_KEY
|
|
36
|
-
valueFrom:
|
|
37
|
-
secretKeyRef:
|
|
38
|
-
name: ${STRIPE_SECRET_KEY}
|
|
39
|
-
key: latest
|
|
40
|
-
- name: STRIPE_WEBHOOK_SECRET
|
|
41
|
-
valueFrom:
|
|
42
|
-
secretKeyRef:
|
|
43
|
-
name: ${STRIPE_WEBHOOK_SECRET}
|
|
44
|
-
key: latest
|
|
45
|
-
- name: REVENUECAT_API_KEY
|
|
46
|
-
valueFrom:
|
|
47
|
-
secretKeyRef:
|
|
48
|
-
name: ${REVENUECAT_API_KEY}
|
|
49
|
-
key: latest
|
|
50
|
-
- name: REVENUECAT_WEBHOOK_SECRET
|
|
51
|
-
valueFrom:
|
|
52
|
-
secretKeyRef:
|
|
53
|
-
name: ${REVENUECAT_WEBHOOK_SECRET}
|
|
54
|
-
key: latest
|
|
55
|
-
- name: RESEND_API_KEY
|
|
56
|
-
valueFrom:
|
|
57
|
-
secretKeyRef:
|
|
58
|
-
name: ${RESEND_API_KEY}
|
|
59
|
-
key: latest
|
|
60
|
-
- name: POSTHOG_API_KEY
|
|
61
|
-
valueFrom:
|
|
62
|
-
secretKeyRef:
|
|
63
|
-
name: ${POSTHOG_API_KEY}
|
|
64
|
-
key: latest
|
|
65
|
-
- name: ATTACHMENT_BUCKET
|
|
66
|
-
value: ${ATTACHMENT_BUCKET}
|
|
67
|
-
- name: ATTACHMENT_PUBLIC_BASE_URL
|
|
68
|
-
value: ${ATTACHMENT_PUBLIC_BASE_URL}
|
|
41
|
+
- name: AUTH_ENABLED
|
|
42
|
+
value: "true"
|
|
43
|
+
- name: AUTH_ISSUER
|
|
44
|
+
value: ${AUTH_ISSUER}
|
|
45
|
+
- name: AUTH_AUDIENCE
|
|
46
|
+
value: ${AUTH_AUDIENCE}
|
|
47
|
+
- name: AUTH_JWKS_URL
|
|
48
|
+
value: ${AUTH_JWKS_URL}
|
|
69
49
|
traffic:
|
|
70
50
|
- latestRevision: true
|
|
71
51
|
percent: 100
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: oven-sh/setup-bun@v2
|
|
15
|
+
- run: bun install
|
|
16
|
+
- run: bun lint
|
|
17
|
+
- run: bun test
|
|
18
|
+
- if: ${{ vars.GCX_ENABLED == 'true' && github.ref == 'refs/heads/main' }}
|
|
19
|
+
run: bun run dashboards
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: Deploy
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
deploy:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- uses: oven-sh/setup-bun@v2
|
|
14
|
+
- run: bun install
|
|
15
|
+
- run: bun run deploy
|
|
16
|
+
env:
|
|
17
|
+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
18
|
+
- if: ${{ vars.GCX_ENABLED == 'true' }}
|
|
19
|
+
run: bun run dashboards
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
.PHONY: dev migrate gen lint test create deploy dashboards auth destroy
|
|
2
|
+
|
|
3
|
+
SERVICE := npx --no-install service
|
|
4
|
+
|
|
5
|
+
dev:
|
|
6
|
+
bun run dev
|
|
7
|
+
|
|
8
|
+
migrate:
|
|
9
|
+
$(SERVICE) migrate
|
|
10
|
+
|
|
11
|
+
gen:
|
|
12
|
+
@echo "no generated code for workers"
|
|
13
|
+
|
|
14
|
+
lint:
|
|
15
|
+
bunx tsc --noEmit
|
|
16
|
+
|
|
17
|
+
test:
|
|
18
|
+
bun test
|
|
19
|
+
|
|
20
|
+
create:
|
|
21
|
+
$(SERVICE) create
|
|
22
|
+
|
|
23
|
+
deploy:
|
|
24
|
+
$(SERVICE) deploy $(ARGS)
|
|
25
|
+
|
|
26
|
+
dashboards:
|
|
27
|
+
$(SERVICE) dashboards
|
|
28
|
+
|
|
29
|
+
auth:
|
|
30
|
+
$(SERVICE) auth $(ARGS)
|
|
31
|
+
|
|
32
|
+
destroy:
|
|
33
|
+
$(SERVICE) destroy $(ARGS)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# {{SERVICE_NAME}}
|
|
2
|
+
|
|
3
|
+
Generated by `create-service`.
|
|
4
|
+
|
|
5
|
+
This `{{PROFILE}}` profile targets `{{RUNTIME}} + {{FRAMEWORK}}` on Cloudflare Workers with:
|
|
6
|
+
|
|
7
|
+
- one `wrangler.toml`
|
|
8
|
+
- a lightweight waitlist/launch API
|
|
9
|
+
- a local `service` CLI for create, deploy, doctor, dashboards, DNS, and destroy
|
|
10
|
+
- Cron Trigger wiring for scheduled follow-up work
|
|
11
|
+
- a Hyperdrive binding for Neon-backed Postgres persistence
|
|
12
|
+
- a production API origin at `https://{{API_HOSTNAME}}`
|
|
13
|
+
|
|
14
|
+
## Commands
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
wrangler dev
|
|
18
|
+
bun run test
|
|
19
|
+
bun run lint
|
|
20
|
+
bun run migrate
|
|
21
|
+
bun run create
|
|
22
|
+
bun run deploy
|
|
23
|
+
bun run dashboards
|
|
24
|
+
bun run doctor
|
|
25
|
+
bun run destroy
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Local Development
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
bun install
|
|
32
|
+
bun run dev
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The Workers target starts with an HTTP waitlist API. Local unit tests use an
|
|
36
|
+
in-memory store. Deployed Workers use the `HYPERDRIVE` binding and create the
|
|
37
|
+
small waitlist/trigger schema on first use.
|
|
38
|
+
|
|
39
|
+
## API
|
|
40
|
+
|
|
41
|
+
- `GET /healthz`
|
|
42
|
+
- `GET /readyz`
|
|
43
|
+
- `POST /v1/waitlist`
|
|
44
|
+
- `GET /v1/waitlist?email=<email>`
|
|
45
|
+
- `GET /v1/waitlist/:entryId`
|
|
46
|
+
- `POST /v1/triggers/waitlist`
|
|
47
|
+
- `POST /webhooks/:provider`
|
|
48
|
+
- `GET /webhooks/:provider/health`
|
|
49
|
+
|
|
50
|
+
## Production
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
bun run create
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`service create` deploys the Worker through Wrangler. The custom domain is
|
|
57
|
+
configured in `wrangler.toml`:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
https://{{API_HOSTNAME}}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Use `bun run doctor` after create to verify Wrangler auth, route config, Cron,
|
|
64
|
+
Hyperdrive, dashboard tooling, auth tooling, and deployed health.
|
|
65
|
+
|
|
66
|
+
If the Hyperdrive binding id is empty, `service create` uses `DATABASE_URL`, or
|
|
67
|
+
`NEON_API_KEY` to create/resolve the generated Neon database and connection URI,
|
|
68
|
+
applies the waitlist schema, then runs `wrangler hyperdrive create` and writes
|
|
69
|
+
the returned id back into `wrangler.toml` before deploy.
|
|
70
|
+
|
|
71
|
+
You can also apply the schema manually:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
DATABASE_URL=postgres://... bun run migrate
|
|
75
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{SERVICE_NAME}}",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"service": "./scripts/workers/cli.ts"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "wrangler dev",
|
|
10
|
+
"service": "bun run ./scripts/workers/cli.ts",
|
|
11
|
+
"migrate": "bun run ./scripts/workers/cli.ts migrate",
|
|
12
|
+
"seed": "bun run ./scripts/workers/cli.ts seed",
|
|
13
|
+
"lint": "bunx tsc --noEmit",
|
|
14
|
+
"test": "bun test",
|
|
15
|
+
"create": "bun run ./scripts/workers/cli.ts create",
|
|
16
|
+
"deploy": "bun run ./scripts/workers/cli.ts deploy",
|
|
17
|
+
"dashboards": "bun run ./scripts/workers/cli.ts dashboards",
|
|
18
|
+
"auth": "bun run ./scripts/workers/cli.ts auth",
|
|
19
|
+
"destroy": "bun run ./scripts/workers/cli.ts destroy"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@anmho/authctl": "0.1.1",
|
|
23
|
+
"@clack/prompts": "^1.2.0",
|
|
24
|
+
"@neondatabase/api-client": "^2.7.1",
|
|
25
|
+
"hono": "^4.10.1",
|
|
26
|
+
"pg": "^8.16.3"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@cloudflare/workers-types": "latest",
|
|
30
|
+
"@types/pg": "^8.16.0",
|
|
31
|
+
"@types/bun": "latest",
|
|
32
|
+
"typescript": "^5.9.3",
|
|
33
|
+
"wrangler": "^4.49.0"
|
|
34
|
+
}
|
|
35
|
+
}
|