create-svc 0.1.9 → 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.
Files changed (163) hide show
  1. package/README.md +138 -16
  2. package/bin/create-service.mjs +2 -0
  3. package/package.json +19 -11
  4. package/src/cli.test.ts +46 -7
  5. package/src/cli.ts +282 -84
  6. package/src/git-bootstrap.test.ts +40 -0
  7. package/src/git-bootstrap.ts +110 -0
  8. package/src/naming.test.ts +5 -2
  9. package/src/naming.ts +32 -1
  10. package/src/neon.ts +10 -8
  11. package/src/post-scaffold.test.ts +19 -0
  12. package/src/post-scaffold.ts +18 -26
  13. package/src/profiles.ts +25 -0
  14. package/src/scaffold.test.ts +320 -18
  15. package/src/scaffold.ts +154 -28
  16. package/src/vault.test.ts +94 -10
  17. package/src/vault.ts +81 -18
  18. package/templates/shared/.github/workflows/ci.yml +2 -1
  19. package/templates/shared/.github/workflows/deploy.yml +2 -0
  20. package/templates/shared/README.md +217 -29
  21. package/templates/shared/docker-compose.yml +19 -0
  22. package/templates/shared/grafana/alerts.yaml +54 -0
  23. package/templates/shared/grafana/waitlist-dashboard.json +63 -0
  24. package/templates/shared/scripts/authctl.ts +231 -0
  25. package/templates/shared/scripts/cloudrun/bootstrap.ts +24 -42
  26. package/templates/shared/scripts/cloudrun/cleanup.ts +81 -35
  27. package/templates/shared/scripts/cloudrun/cli.ts +324 -7
  28. package/templates/shared/scripts/cloudrun/config.ts +21 -19
  29. package/templates/shared/scripts/cloudrun/deploy.ts +16 -11
  30. package/templates/shared/scripts/cloudrun/lib.ts +232 -123
  31. package/templates/shared/scripts/cloudrun/neon.ts +127 -13
  32. package/templates/shared/scripts/dev.ts +22 -0
  33. package/templates/shared/scripts/ensure-local-db.ts +3 -0
  34. package/templates/shared/scripts/local-docker.ts +63 -0
  35. package/templates/shared/scripts/local-env.ts +27 -0
  36. package/templates/shared/scripts/seed.ts +73 -0
  37. package/templates/shared/scripts/wait-for-db.ts +32 -0
  38. package/templates/shared/service.config.ts +59 -0
  39. package/templates/shared/service.yaml +24 -1
  40. package/templates/targets/workers/.github/workflows/ci.yml +19 -0
  41. package/templates/targets/workers/.github/workflows/deploy.yml +19 -0
  42. package/templates/targets/workers/Makefile +33 -0
  43. package/templates/targets/workers/README.md +75 -0
  44. package/templates/targets/workers/package.json +35 -0
  45. package/templates/targets/workers/scripts/workers/cli.ts +397 -0
  46. package/templates/targets/workers/src/auth.ts +178 -0
  47. package/templates/targets/workers/src/index.ts +198 -0
  48. package/templates/targets/workers/src/storage.ts +370 -0
  49. package/templates/targets/workers/test/app.test.ts +108 -0
  50. package/templates/targets/workers/tsconfig.json +11 -0
  51. package/templates/targets/workers/wrangler.toml +24 -0
  52. package/templates/variants/bun-connectrpc/Dockerfile +1 -0
  53. package/templates/variants/bun-connectrpc/Makefile +17 -8
  54. package/templates/variants/bun-connectrpc/gen/protos/waitlist/v1/waitlist_pb.ts +424 -0
  55. package/templates/variants/bun-connectrpc/migrations/0000_init.sql +20 -0
  56. package/templates/variants/bun-connectrpc/package.json +25 -1
  57. package/templates/variants/bun-connectrpc/protos/waitlist/v1/waitlist.proto +91 -0
  58. package/templates/variants/bun-connectrpc/scripts/codegen.ts +31 -1
  59. package/templates/variants/bun-connectrpc/scripts/migrate.ts +49 -0
  60. package/templates/variants/bun-connectrpc/src/auth.ts +200 -0
  61. package/templates/variants/bun-connectrpc/src/db/client.ts +15 -0
  62. package/templates/variants/bun-connectrpc/src/db/repository.ts +126 -0
  63. package/templates/variants/bun-connectrpc/src/db/schema.ts +26 -0
  64. package/templates/variants/bun-connectrpc/src/index.ts +194 -22
  65. package/templates/variants/bun-connectrpc/src/temporal/activities.ts +14 -0
  66. package/templates/variants/bun-connectrpc/src/temporal/worker.ts +38 -0
  67. package/templates/variants/bun-connectrpc/src/temporal/workflows.ts +10 -0
  68. package/templates/variants/bun-connectrpc/src/waitlist/service.ts +172 -0
  69. package/templates/variants/bun-connectrpc/src/waitlist/types.ts +45 -0
  70. package/templates/variants/bun-connectrpc/test/app.test.ts +14 -13
  71. package/templates/variants/bun-connectrpc/test/waitlist.integration.test.ts +71 -0
  72. package/templates/variants/bun-connectrpc/tsconfig.json +2 -1
  73. package/templates/variants/bun-hono/Makefile +17 -8
  74. package/templates/variants/bun-hono/migrations/0000_init.sql +20 -0
  75. package/templates/variants/bun-hono/package.json +21 -1
  76. package/templates/variants/bun-hono/scripts/migrate.ts +49 -0
  77. package/templates/variants/bun-hono/src/auth.ts +181 -0
  78. package/templates/variants/bun-hono/src/db/client.ts +15 -0
  79. package/templates/variants/bun-hono/src/db/repository.ts +126 -0
  80. package/templates/variants/bun-hono/src/db/schema.ts +26 -0
  81. package/templates/variants/bun-hono/src/index.ts +141 -10
  82. package/templates/variants/bun-hono/src/temporal/activities.ts +14 -0
  83. package/templates/variants/bun-hono/src/temporal/worker.ts +38 -0
  84. package/templates/variants/bun-hono/src/temporal/workflows.ts +10 -0
  85. package/templates/variants/bun-hono/src/waitlist/service.ts +166 -0
  86. package/templates/variants/bun-hono/src/waitlist/types.ts +50 -0
  87. package/templates/variants/bun-hono/test/app.test.ts +90 -5
  88. package/templates/variants/bun-hono/test/waitlist.integration.test.ts +102 -0
  89. package/templates/variants/bun-hono/tsconfig.json +1 -0
  90. package/templates/variants/go-chi/Makefile +30 -10
  91. package/templates/variants/go-chi/atlas.hcl +8 -0
  92. package/templates/variants/go-chi/cmd/server/main.go +25 -13
  93. package/templates/variants/go-chi/go.mod +3 -2
  94. package/templates/variants/go-chi/internal/app/service.go +279 -70
  95. package/templates/variants/go-chi/internal/auth/middleware.go +289 -0
  96. package/templates/variants/go-chi/internal/auth/middleware_test.go +38 -0
  97. package/templates/variants/go-chi/internal/config/config.go +38 -7
  98. package/templates/variants/go-chi/internal/httpapi/routes.go +170 -47
  99. package/templates/variants/go-chi/internal/httpapi/waitlist_integration_test.go +199 -0
  100. package/templates/variants/go-chi/internal/temporal/activities.go +27 -0
  101. package/templates/variants/go-chi/internal/temporal/worker.go +42 -0
  102. package/templates/variants/go-chi/internal/temporal/workflows.go +18 -0
  103. package/templates/variants/go-chi/migrations/0000_init.sql +20 -0
  104. package/templates/variants/go-chi/migrations/atlas.sum +2 -0
  105. package/templates/variants/go-chi/package.json +7 -1
  106. package/templates/variants/go-chi/test/go.test.ts +4 -1
  107. package/templates/variants/go-connectrpc/Makefile +29 -8
  108. package/templates/variants/go-connectrpc/atlas.hcl +8 -0
  109. package/templates/variants/go-connectrpc/buf.gen.yaml +2 -0
  110. package/templates/variants/go-connectrpc/cmd/server/main.go +44 -9
  111. package/templates/variants/go-connectrpc/gen/waitlist/v1/waitlist.pb.go +960 -0
  112. package/templates/variants/go-connectrpc/gen/waitlist/v1/waitlistv1connect/waitlist.connect.go +283 -0
  113. package/templates/variants/go-connectrpc/go.mod +4 -0
  114. package/templates/variants/go-connectrpc/internal/app/service.go +279 -70
  115. package/templates/variants/go-connectrpc/internal/auth/middleware.go +289 -0
  116. package/templates/variants/go-connectrpc/internal/auth/middleware_test.go +38 -0
  117. package/templates/variants/go-connectrpc/internal/config/config.go +38 -7
  118. package/templates/variants/go-connectrpc/internal/connectapi/handler.go +129 -40
  119. package/templates/variants/go-connectrpc/internal/connectapi/waitlist_integration_test.go +122 -0
  120. package/templates/variants/go-connectrpc/internal/httpapi/routes.go +170 -47
  121. package/templates/variants/go-connectrpc/internal/temporal/activities.go +27 -0
  122. package/templates/variants/go-connectrpc/internal/temporal/worker.go +42 -0
  123. package/templates/variants/go-connectrpc/internal/temporal/workflows.go +18 -0
  124. package/templates/variants/go-connectrpc/migrations/0000_init.sql +20 -0
  125. package/templates/variants/go-connectrpc/migrations/atlas.sum +2 -0
  126. package/templates/variants/go-connectrpc/package.json +7 -1
  127. package/templates/variants/go-connectrpc/protos/waitlist/v1/waitlist.proto +93 -0
  128. package/templates/root/.github/workflows/buf-publish.yml +0 -19
  129. package/templates/root/.github/workflows/ci.yml +0 -26
  130. package/templates/root/.github/workflows/deploy.yml +0 -22
  131. package/templates/root/Dockerfile +0 -23
  132. package/templates/root/README.md +0 -69
  133. package/templates/root/buf.gen.yaml +0 -10
  134. package/templates/root/buf.yaml +0 -9
  135. package/templates/root/cmd/server/main.go +0 -44
  136. package/templates/root/gen/dns/v1/dns.pb.go +0 -623
  137. package/templates/root/gen/dns/v1/dnsv1connect/dns.connect.go +0 -192
  138. package/templates/root/go.mod +0 -10
  139. package/templates/root/internal/app/service.go +0 -152
  140. package/templates/root/internal/app/token_source.go +0 -50
  141. package/templates/root/internal/cloudflare/client.go +0 -160
  142. package/templates/root/internal/config/config.go +0 -55
  143. package/templates/root/internal/connectapi/handler.go +0 -79
  144. package/templates/root/internal/httpapi/routes.go +0 -93
  145. package/templates/root/internal/vault/client.go +0 -148
  146. package/templates/root/package.json +0 -12
  147. package/templates/root/protos/dns/v1/dns.proto +0 -58
  148. package/templates/root/scripts/cloudrun/bootstrap.ts +0 -65
  149. package/templates/root/scripts/cloudrun/config.ts +0 -50
  150. package/templates/root/scripts/cloudrun/deploy.ts +0 -41
  151. package/templates/root/scripts/cloudrun/lib.ts +0 -244
  152. package/templates/root/service.yaml +0 -50
  153. package/templates/root/test/go.test.ts +0 -19
  154. package/templates/shared/.env.example +0 -10
  155. package/templates/variants/go-chi/buf.gen.yaml +0 -10
  156. package/templates/variants/go-chi/buf.yaml +0 -9
  157. package/templates/variants/go-chi/gen/dns/v1/dns.pb.go +0 -623
  158. package/templates/variants/go-chi/gen/dns/v1/dnsv1connect/dns.connect.go +0 -192
  159. package/templates/variants/go-chi/internal/connectapi/handler.go +0 -79
  160. package/templates/variants/go-chi/protos/dns/v1/dns.proto +0 -58
  161. package/templates/variants/go-connectrpc/gen/dns/v1/dns.pb.go +0 -623
  162. package/templates/variants/go-connectrpc/gen/dns/v1/dnsv1connect/dns.connect.go +0 -192
  163. package/templates/variants/go-connectrpc/protos/dns/v1/dns.proto +0 -58
@@ -0,0 +1,27 @@
1
+ package temporalapp
2
+
3
+ import "context"
4
+
5
+ type WaitlistFollowUpInput struct {
6
+ TriggerID string
7
+ Email string
8
+ Type string
9
+ }
10
+
11
+ type WaitlistFollowUpResult struct {
12
+ Status string
13
+ TriggerID string
14
+ Email string
15
+ Type string
16
+ }
17
+
18
+ type Activities struct{}
19
+
20
+ func (a *Activities) RecordWaitlistFollowUp(ctx context.Context, input WaitlistFollowUpInput) (WaitlistFollowUpResult, error) {
21
+ return WaitlistFollowUpResult{
22
+ Status: "queued",
23
+ TriggerID: input.TriggerID,
24
+ Email: input.Email,
25
+ Type: input.Type,
26
+ }, nil
27
+ }
@@ -0,0 +1,42 @@
1
+ package temporalapp
2
+
3
+ import (
4
+ "go.temporal.io/sdk/client"
5
+ "go.temporal.io/sdk/worker"
6
+ )
7
+
8
+ type WorkerConfig struct {
9
+ Address string
10
+ Namespace string
11
+ TaskQueue string
12
+ APIKey string
13
+ }
14
+
15
+ func StartWorker(cfg WorkerConfig) (func(), error) {
16
+ options := client.Options{
17
+ HostPort: cfg.Address,
18
+ Namespace: cfg.Namespace,
19
+ }
20
+ if cfg.APIKey != "" {
21
+ options.Credentials = client.NewAPIKeyStaticCredentials(cfg.APIKey)
22
+ }
23
+
24
+ temporalClient, err := client.Dial(options)
25
+ if err != nil {
26
+ return nil, err
27
+ }
28
+
29
+ temporalWorker := worker.New(temporalClient, cfg.TaskQueue, worker.Options{})
30
+ temporalWorker.RegisterWorkflow(WaitlistFollowUpWorkflow)
31
+ temporalWorker.RegisterActivity(&Activities{})
32
+
33
+ if err := temporalWorker.Start(); err != nil {
34
+ temporalClient.Close()
35
+ return nil, err
36
+ }
37
+
38
+ return func() {
39
+ temporalWorker.Stop()
40
+ temporalClient.Close()
41
+ }, nil
42
+ }
@@ -0,0 +1,18 @@
1
+ package temporalapp
2
+
3
+ import (
4
+ "time"
5
+
6
+ "go.temporal.io/sdk/workflow"
7
+ )
8
+
9
+ func WaitlistFollowUpWorkflow(ctx workflow.Context, input WaitlistFollowUpInput) (WaitlistFollowUpResult, error) {
10
+ options := workflow.ActivityOptions{
11
+ StartToCloseTimeout: time.Minute,
12
+ }
13
+ ctx = workflow.WithActivityOptions(ctx, options)
14
+
15
+ var result WaitlistFollowUpResult
16
+ err := workflow.ExecuteActivity(ctx, "RecordWaitlistFollowUp", input).Get(ctx, &result)
17
+ return result, err
18
+ }
@@ -0,0 +1,20 @@
1
+ create table if not exists waitlist_entries (
2
+ id text primary key,
3
+ email text not null unique,
4
+ name text,
5
+ company text,
6
+ source text,
7
+ status text not null default 'joined',
8
+ created_at timestamptz not null default now(),
9
+ updated_at timestamptz not null default now()
10
+ );
11
+
12
+ create table if not exists waitlist_triggers (
13
+ id text primary key,
14
+ type text not null,
15
+ entry_id text references waitlist_entries(id),
16
+ status text not null default 'queued',
17
+ payload_json text not null,
18
+ created_at timestamptz not null default now(),
19
+ processed_at timestamptz
20
+ );
@@ -0,0 +1,2 @@
1
+ h1:D9GgvtEf0xxnRDaTb/C3cPtRbncVXsK6Ef0KYQuLMRw=
2
+ 0000_init.sql h1:dBpLGyoeZNRpjT6RvQXiqx3p2ICAChKy2jVqCIYuWQg=
@@ -3,9 +3,15 @@
3
3
  "private": true,
4
4
  "type": "module",
5
5
  "bin": {
6
- "svc-cloudrun": "./scripts/cloudrun/cli.ts"
6
+ "service": "./scripts/cloudrun/cli.ts"
7
+ },
8
+ "scripts": {
9
+ "service": "bun run ./scripts/cloudrun/cli.ts",
10
+ "auth": "bun run ./scripts/cloudrun/cli.ts auth",
11
+ "dashboards": "bun run ./scripts/cloudrun/cli.ts dashboards"
7
12
  },
8
13
  "dependencies": {
14
+ "@anmho/authctl": "0.1.1",
9
15
  "@clack/prompts": "^1.2.0",
10
16
  "@neondatabase/api-client": "^2.7.1"
11
17
  }
@@ -0,0 +1,93 @@
1
+ syntax = "proto3";
2
+
3
+ package waitlist.v1;
4
+
5
+ option go_package = "{{MODULE_PATH}}/gen/waitlist/v1;waitlistv1";
6
+
7
+ service WaitlistService {
8
+ rpc JoinWaitlist(JoinWaitlistRequest) returns (JoinWaitlistResponse);
9
+ rpc GetWaitlistEntry(GetWaitlistEntryRequest) returns (GetWaitlistEntryResponse);
10
+ rpc GetWaitlistEntryByEmail(GetWaitlistEntryByEmailRequest) returns (GetWaitlistEntryResponse);
11
+ rpc ListWaitlistEntries(ListWaitlistEntriesRequest) returns (ListWaitlistEntriesResponse);
12
+ rpc UpdateWaitlistEntry(UpdateWaitlistEntryRequest) returns (GetWaitlistEntryResponse);
13
+ rpc ExportWaitlistEntries(ExportWaitlistEntriesRequest) returns (ExportWaitlistEntriesResponse);
14
+ rpc RecordTrigger(RecordTriggerRequest) returns (RecordTriggerResponse);
15
+ }
16
+
17
+ message WaitlistEntry {
18
+ string id = 1;
19
+ string email = 2;
20
+ string name = 3;
21
+ string company = 4;
22
+ string source = 5;
23
+ string status = 6;
24
+ string created_at = 7;
25
+ string updated_at = 8;
26
+ }
27
+
28
+ message WaitlistTrigger {
29
+ string id = 1;
30
+ string type = 2;
31
+ string entry_id = 3;
32
+ string status = 4;
33
+ string payload_json = 5;
34
+ string created_at = 6;
35
+ string processed_at = 7;
36
+ }
37
+
38
+ message JoinWaitlistRequest {
39
+ string email = 1;
40
+ string name = 2;
41
+ string company = 3;
42
+ string source = 4;
43
+ }
44
+
45
+ message JoinWaitlistResponse {
46
+ WaitlistEntry entry = 1;
47
+ bool created = 2;
48
+ }
49
+
50
+ message GetWaitlistEntryRequest {
51
+ string entry_id = 1;
52
+ }
53
+
54
+ message GetWaitlistEntryByEmailRequest {
55
+ string email = 1;
56
+ }
57
+
58
+ message GetWaitlistEntryResponse {
59
+ WaitlistEntry entry = 1;
60
+ }
61
+
62
+ message ListWaitlistEntriesRequest {
63
+ string status = 1;
64
+ uint32 limit = 2;
65
+ }
66
+
67
+ message ListWaitlistEntriesResponse {
68
+ repeated WaitlistEntry entries = 1;
69
+ }
70
+
71
+ message UpdateWaitlistEntryRequest {
72
+ string entry_id = 1;
73
+ string status = 2;
74
+ }
75
+
76
+ message ExportWaitlistEntriesRequest {
77
+ string status = 1;
78
+ uint32 limit = 2;
79
+ }
80
+
81
+ message ExportWaitlistEntriesResponse {
82
+ string csv = 1;
83
+ }
84
+
85
+ message RecordTriggerRequest {
86
+ string type = 1;
87
+ string entry_id = 2;
88
+ string payload_json = 3;
89
+ }
90
+
91
+ message RecordTriggerResponse {
92
+ WaitlistTrigger trigger = 1;
93
+ }
@@ -1,19 +0,0 @@
1
- name: buf-publish
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- paths:
8
- - "protos/**"
9
-
10
- jobs:
11
- publish:
12
- if: ${{ vars.BUF_MODULE != '' }}
13
- runs-on: ubuntu-latest
14
- steps:
15
- - uses: actions/checkout@v4
16
- - uses: bufbuild/buf-setup-action@v1
17
- - run: buf push
18
- env:
19
- BUF_TOKEN: ${{ secrets.BUF_TOKEN }}
@@ -1,26 +0,0 @@
1
- name: ci
2
-
3
- on:
4
- pull_request:
5
- push:
6
- branches:
7
- - main
8
-
9
- jobs:
10
- test:
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/checkout@v4
14
- - uses: actions/setup-go@v5
15
- with:
16
- go-version: '1.25.4'
17
- - uses: oven-sh/setup-bun@v2
18
- - uses: bufbuild/buf-setup-action@v1
19
- - name: Install proto plugins
20
- run: |
21
- go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.10
22
- go install connectrpc.com/connect/cmd/protoc-gen-connect-go@v1.19.1
23
- echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
24
- - run: bun gen
25
- - run: bun lint
26
- - run: bun test
@@ -1,22 +0,0 @@
1
- name: deploy
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- jobs:
9
- deploy:
10
- runs-on: ubuntu-latest
11
- permissions:
12
- contents: read
13
- id-token: write
14
- steps:
15
- - uses: actions/checkout@v4
16
- - uses: oven-sh/setup-bun@v2
17
- - uses: google-github-actions/auth@v3
18
- with:
19
- workload_identity_provider: ${{ vars.GCP_WIF_PROVIDER }}
20
- service_account: ${{ vars.GCP_DEPLOYER_SERVICE_ACCOUNT }}
21
- - uses: google-github-actions/setup-gcloud@v2
22
- - run: bun run deploy -- --ci
@@ -1,23 +0,0 @@
1
- FROM golang:1.25.4 AS builder
2
-
3
- WORKDIR /app
4
-
5
- COPY go.mod ./
6
- COPY gen ./gen
7
- COPY internal ./internal
8
- COPY cmd ./cmd
9
-
10
- RUN go mod download
11
- RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /out/server ./cmd/server
12
-
13
- FROM gcr.io/distroless/base-debian12
14
-
15
- WORKDIR /app
16
-
17
- COPY --from=builder /out/server /app/server
18
-
19
- ENV PORT=8080
20
-
21
- EXPOSE 8080
22
-
23
- ENTRYPOINT ["/app/server"]
@@ -1,69 +0,0 @@
1
- # {{SERVICE_NAME}}
2
-
3
- Cloud Run API scaffold generated by `create-service`.
4
-
5
- ## What it includes
6
-
7
- - Chi HTTP routes
8
- - ConnectRPC handlers
9
- - real Cloud Run service manifest in [service.yaml](service.yaml)
10
- - Bun-based Cloud Run deploy config in [scripts/cloudrun/config.ts](scripts/cloudrun/config.ts)
11
- - Vault-backed Cloudflare DNS CRUD example
12
- - script-first deployment via Bun
13
-
14
- ## Prerequisites
15
-
16
- - Bun
17
- - Go 1.25+
18
- - `gcloud`
19
- - `gh`
20
- - `buf`
21
- - `protoc`
22
- - `protoc-gen-go`
23
- - `protoc-gen-connect-go`
24
-
25
- Install the Go protobuf plugins:
26
-
27
- ```bash
28
- go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.10
29
- go install connectrpc.com/connect/cmd/protoc-gen-connect-go@v1.19.1
30
- ```
31
-
32
- ## Commands
33
-
34
- ```bash
35
- bun dev
36
- bun gen
37
- bun lint
38
- bun test
39
- bun run deploy
40
- ```
41
-
42
- `bun test` uses Bun's test runner to invoke `go test ./...` so the command surface stays Bun-first.
43
-
44
- ## First deploy
45
-
46
- The runtime reads Vault AppRole credentials from Secret Manager. On the first deploy, seed those two secret values locally:
47
-
48
- ```bash
49
- export BOOTSTRAP_VAULT_ROLE_ID=...
50
- export BOOTSTRAP_VAULT_SECRET_ID=...
51
- bun run deploy
52
- ```
53
-
54
- `bun run deploy` will:
55
-
56
- 1. enable required GCP services
57
- 2. create runtime and deployer service accounts
58
- 3. create the Secret Manager secrets if missing
59
- 4. wire GitHub OIDC for `main` deploys
60
- 5. build the image and apply the Cloud Run manifest through the Bun deploy helper
61
-
62
- ## Local fallback
63
-
64
- For local development, you can skip Vault and provide the Cloudflare token directly:
65
-
66
- ```bash
67
- export CLOUDFLARE_API_TOKEN=...
68
- bun dev
69
- ```
@@ -1,10 +0,0 @@
1
- version: v2
2
- plugins:
3
- - local: protoc-gen-go
4
- out: gen
5
- opt:
6
- - paths=source_relative
7
- - local: protoc-gen-connect-go
8
- out: gen
9
- opt:
10
- - paths=source_relative
@@ -1,9 +0,0 @@
1
- version: v2
2
- modules:
3
- - path: protos
4
- lint:
5
- use:
6
- - STANDARD
7
- breaking:
8
- use:
9
- - FILE
@@ -1,44 +0,0 @@
1
- package main
2
-
3
- import (
4
- "log"
5
- "net/http"
6
- "time"
7
-
8
- "github.com/go-chi/chi/v5"
9
- "golang.org/x/net/http2"
10
- "golang.org/x/net/http2/h2c"
11
-
12
- "{{MODULE_PATH}}/internal/app"
13
- "{{MODULE_PATH}}/internal/config"
14
- "{{MODULE_PATH}}/internal/connectapi"
15
- "{{MODULE_PATH}}/internal/httpapi"
16
- "{{MODULE_PATH}}/internal/vault"
17
- )
18
-
19
- func main() {
20
- cfg, err := config.Load()
21
- if err != nil {
22
- log.Fatal(err)
23
- }
24
-
25
- httpClient := &http.Client{Timeout: 15 * time.Second}
26
- vaultClient := vault.NewAppRoleClient(cfg.VaultAddr, cfg.VaultRoleIDFile, cfg.VaultSecretIDFile, httpClient)
27
- tokenSource := app.NewCloudflareTokenSource(vaultClient, cfg.VaultSecretPath, cfg.VaultSecretKey)
28
- service := app.NewDNSService(cfg.CloudflareZoneID, cfg.CloudflareAPIBaseURL, tokenSource)
29
-
30
- router := chi.NewRouter()
31
- httpapi.RegisterRoutes(router, service)
32
-
33
- connectPath, connectHandler := connectapi.NewHandler(service)
34
- router.Mount(connectPath, connectHandler)
35
-
36
- server := &http.Server{
37
- Addr: ":" + cfg.Port,
38
- ReadHeaderTimeout: 10 * time.Second,
39
- Handler: h2c.NewHandler(router, &http2.Server{}),
40
- }
41
-
42
- log.Printf("listening on %s", server.Addr)
43
- log.Fatal(server.ListenAndServe())
44
- }