create-svc 0.1.2 → 0.1.4
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 +6 -3
- package/src/cli.ts +328 -108
- package/src/gcp.test.ts +71 -0
- package/src/gcp.ts +97 -0
- package/src/naming.test.ts +37 -0
- package/src/naming.ts +103 -0
- package/src/neon.test.ts +48 -0
- package/src/neon.ts +76 -0
- package/src/post-scaffold.ts +77 -0
- package/src/scaffold.test.ts +66 -31
- package/src/scaffold.ts +60 -55
- package/templates/shared/.github/workflows/ci.yml +22 -0
- package/templates/shared/.github/workflows/deploy.yml +30 -0
- package/templates/shared/.github/workflows/personal.yml +41 -0
- package/templates/shared/.github/workflows/preview-cleanup.yml +25 -0
- package/templates/shared/.github/workflows/preview.yml +29 -0
- package/templates/shared/README.md +37 -0
- package/templates/shared/scripts/cloudrun/bootstrap.ts +76 -0
- package/templates/shared/scripts/cloudrun/config.ts +57 -0
- package/templates/shared/scripts/cloudrun/deploy.ts +82 -0
- package/templates/shared/scripts/cloudrun/lib.ts +380 -0
- package/templates/shared/scripts/cloudrun/neon.ts +104 -0
- package/templates/shared/service.yaml +28 -0
- package/templates/variants/bun-connectrpc/Dockerfile +13 -0
- package/templates/variants/bun-connectrpc/package.json +20 -0
- package/templates/variants/bun-connectrpc/scripts/codegen.ts +1 -0
- package/templates/variants/bun-connectrpc/src/index.ts +32 -0
- package/templates/variants/bun-connectrpc/test/app.test.ts +17 -0
- package/templates/variants/bun-connectrpc/tsconfig.json +10 -0
- package/templates/variants/bun-hono/Dockerfile +13 -0
- package/templates/variants/bun-hono/package.json +21 -0
- package/templates/variants/bun-hono/scripts/codegen.ts +1 -0
- package/templates/variants/bun-hono/src/index.ts +24 -0
- package/templates/variants/bun-hono/test/app.test.ts +12 -0
- package/templates/variants/bun-hono/tsconfig.json +10 -0
- package/templates/variants/go-chi/Dockerfile +23 -0
- package/templates/variants/go-chi/buf.gen.yaml +10 -0
- package/templates/variants/go-chi/buf.yaml +9 -0
- package/templates/variants/go-chi/cmd/server/main.go +52 -0
- package/templates/variants/go-chi/gen/dns/v1/dns.pb.go +623 -0
- package/templates/variants/go-chi/gen/dns/v1/dnsv1connect/dns.connect.go +192 -0
- package/templates/variants/go-chi/go.mod +10 -0
- package/templates/variants/go-chi/internal/app/service.go +109 -0
- package/templates/variants/go-chi/internal/app/token_source.go +50 -0
- package/templates/variants/go-chi/internal/cloudflare/client.go +160 -0
- package/templates/variants/go-chi/internal/config/config.go +23 -0
- package/templates/variants/go-chi/internal/connectapi/handler.go +79 -0
- package/templates/variants/go-chi/internal/httpapi/routes.go +93 -0
- package/templates/variants/go-chi/internal/vault/client.go +148 -0
- package/templates/variants/go-chi/package.json +16 -0
- package/templates/variants/go-chi/protos/dns/v1/dns.proto +58 -0
- package/templates/variants/go-chi/test/go.test.ts +19 -0
- package/templates/variants/go-connectrpc/Dockerfile +23 -0
- package/templates/variants/go-connectrpc/buf.gen.yaml +10 -0
- package/templates/variants/go-connectrpc/buf.yaml +9 -0
- package/templates/variants/go-connectrpc/cmd/server/main.go +51 -0
- package/templates/variants/go-connectrpc/gen/dns/v1/dns.pb.go +623 -0
- package/templates/variants/go-connectrpc/gen/dns/v1/dnsv1connect/dns.connect.go +192 -0
- package/templates/variants/go-connectrpc/go.mod +10 -0
- package/templates/variants/go-connectrpc/internal/app/service.go +109 -0
- package/templates/variants/go-connectrpc/internal/app/token_source.go +50 -0
- package/templates/variants/go-connectrpc/internal/cloudflare/client.go +160 -0
- package/templates/variants/go-connectrpc/internal/config/config.go +23 -0
- package/templates/variants/go-connectrpc/internal/connectapi/handler.go +79 -0
- package/templates/variants/go-connectrpc/internal/httpapi/routes.go +93 -0
- package/templates/variants/go-connectrpc/internal/vault/client.go +148 -0
- package/templates/variants/go-connectrpc/package.json +16 -0
- package/templates/variants/go-connectrpc/protos/dns/v1/dns.proto +58 -0
- package/templates/variants/go-connectrpc/test/go.test.ts +19 -0
|
@@ -0,0 +1,23 @@
|
|
|
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"]
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"log"
|
|
6
|
+
"net/http"
|
|
7
|
+
"time"
|
|
8
|
+
|
|
9
|
+
"github.com/go-chi/chi/v5"
|
|
10
|
+
"golang.org/x/net/http2"
|
|
11
|
+
"golang.org/x/net/http2/h2c"
|
|
12
|
+
|
|
13
|
+
"{{MODULE_PATH}}/internal/app"
|
|
14
|
+
"{{MODULE_PATH}}/internal/config"
|
|
15
|
+
"{{MODULE_PATH}}/internal/connectapi"
|
|
16
|
+
"{{MODULE_PATH}}/internal/httpapi"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
func main() {
|
|
20
|
+
cfg, err := config.Load()
|
|
21
|
+
if err != nil {
|
|
22
|
+
log.Fatal(err)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
service := app.NewDNSService()
|
|
26
|
+
if cfg.DatabaseURL != "" {
|
|
27
|
+
if _, err := service.CreateRecord(context.Background(), app.CreateRecordInput{
|
|
28
|
+
Type: "TXT",
|
|
29
|
+
Name: "bootstrap",
|
|
30
|
+
Content: "database-configured",
|
|
31
|
+
TTL: 60,
|
|
32
|
+
Proxied: false,
|
|
33
|
+
}); err != nil {
|
|
34
|
+
log.Fatal(err)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
router := chi.NewRouter()
|
|
39
|
+
httpapi.RegisterRoutes(router, service)
|
|
40
|
+
|
|
41
|
+
connectPath, connectHandler := connectapi.NewHandler(service)
|
|
42
|
+
router.Mount(connectPath, connectHandler)
|
|
43
|
+
|
|
44
|
+
server := &http.Server{
|
|
45
|
+
Addr: ":" + cfg.Port,
|
|
46
|
+
ReadHeaderTimeout: 10 * time.Second,
|
|
47
|
+
Handler: h2c.NewHandler(router, &http2.Server{}),
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
log.Printf("listening on %s", server.Addr)
|
|
51
|
+
log.Fatal(server.ListenAndServe())
|
|
52
|
+
}
|