create-svc 0.1.8 → 0.1.10

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 (91) hide show
  1. package/README.md +142 -13
  2. package/package.json +9 -4
  3. package/src/cli.test.ts +29 -8
  4. package/src/cli.ts +103 -70
  5. package/src/naming.test.ts +4 -2
  6. package/src/naming.ts +9 -1
  7. package/src/neon.ts +10 -8
  8. package/src/post-scaffold.ts +7 -28
  9. package/src/profiles.ts +28 -0
  10. package/src/scaffold.test.ts +126 -15
  11. package/src/scaffold.ts +94 -23
  12. package/src/vault.test.ts +62 -5
  13. package/src/vault.ts +24 -4
  14. package/templates/shared/README.md +143 -26
  15. package/templates/shared/docker-compose.yml +19 -0
  16. package/templates/shared/scripts/cloudrun/bootstrap.ts +15 -42
  17. package/templates/shared/scripts/cloudrun/cleanup.ts +17 -31
  18. package/templates/shared/scripts/cloudrun/config.ts +14 -19
  19. package/templates/shared/scripts/cloudrun/deploy.ts +19 -10
  20. package/templates/shared/scripts/cloudrun/integrations.ts +111 -0
  21. package/templates/shared/scripts/cloudrun/lib.ts +88 -112
  22. package/templates/shared/scripts/cloudrun/neon.ts +100 -14
  23. package/templates/shared/service.yaml +44 -1
  24. package/templates/variants/bun-connectrpc/Dockerfile +1 -0
  25. package/templates/variants/bun-connectrpc/Makefile +4 -1
  26. package/templates/variants/bun-connectrpc/gen/protos/chat/v1/chat_pb.ts +1078 -0
  27. package/templates/variants/bun-connectrpc/migrations/0000_init.sql +63 -0
  28. package/templates/variants/bun-connectrpc/package.json +17 -0
  29. package/templates/variants/bun-connectrpc/protos/chat/v1/chat.proto +228 -0
  30. package/templates/variants/bun-connectrpc/scripts/codegen.ts +31 -1
  31. package/templates/variants/bun-connectrpc/scripts/migrate.ts +46 -0
  32. package/templates/variants/bun-connectrpc/src/chat/service.ts +384 -0
  33. package/templates/variants/bun-connectrpc/src/chat/types.ts +142 -0
  34. package/templates/variants/bun-connectrpc/src/db/client.ts +15 -0
  35. package/templates/variants/bun-connectrpc/src/db/repository.ts +479 -0
  36. package/templates/variants/bun-connectrpc/src/db/schema.ts +75 -0
  37. package/templates/variants/bun-connectrpc/src/index.ts +294 -22
  38. package/templates/variants/bun-connectrpc/src/storage.ts +72 -0
  39. package/templates/variants/bun-connectrpc/src/webhooks.ts +35 -0
  40. package/templates/variants/bun-connectrpc/test/app.test.ts +14 -13
  41. package/templates/variants/bun-connectrpc/test/list-messages.integration.test.ts +182 -0
  42. package/templates/variants/bun-connectrpc/tsconfig.json +2 -1
  43. package/templates/variants/bun-hono/Makefile +4 -1
  44. package/templates/variants/bun-hono/migrations/0000_init.sql +63 -0
  45. package/templates/variants/bun-hono/package.json +13 -0
  46. package/templates/variants/bun-hono/scripts/migrate.ts +46 -0
  47. package/templates/variants/bun-hono/src/chat/service.ts +384 -0
  48. package/templates/variants/bun-hono/src/chat/types.ts +142 -0
  49. package/templates/variants/bun-hono/src/db/client.ts +15 -0
  50. package/templates/variants/bun-hono/src/db/repository.ts +479 -0
  51. package/templates/variants/bun-hono/src/db/schema.ts +75 -0
  52. package/templates/variants/bun-hono/src/index.ts +254 -8
  53. package/templates/variants/bun-hono/src/storage.ts +72 -0
  54. package/templates/variants/bun-hono/src/webhooks.ts +35 -0
  55. package/templates/variants/bun-hono/test/app.test.ts +60 -6
  56. package/templates/variants/bun-hono/test/list-messages.integration.test.ts +256 -0
  57. package/templates/variants/bun-hono/tsconfig.json +1 -0
  58. package/templates/variants/go-chi/Makefile +6 -2
  59. package/templates/variants/go-chi/buf.gen.yaml +2 -0
  60. package/templates/variants/go-chi/cmd/migrate/main.go +101 -0
  61. package/templates/variants/go-chi/cmd/server/main.go +16 -15
  62. package/templates/variants/go-chi/go.mod +3 -0
  63. package/templates/variants/go-chi/internal/app/service.go +763 -71
  64. package/templates/variants/go-chi/internal/config/config.go +22 -7
  65. package/templates/variants/go-chi/internal/httpapi/list_messages_integration_test.go +298 -0
  66. package/templates/variants/go-chi/internal/httpapi/routes.go +245 -43
  67. package/templates/variants/go-chi/migrations/0000_init.sql +63 -0
  68. package/templates/variants/go-chi/protos/chat/v1/chat.proto +219 -0
  69. package/templates/variants/go-chi/test/go.test.ts +4 -1
  70. package/templates/variants/go-connectrpc/Makefile +6 -2
  71. package/templates/variants/go-connectrpc/buf.gen.yaml +2 -0
  72. package/templates/variants/go-connectrpc/cmd/migrate/main.go +101 -0
  73. package/templates/variants/go-connectrpc/cmd/server/main.go +35 -11
  74. package/templates/variants/go-connectrpc/gen/chat/v1/chat.pb.go +2512 -0
  75. package/templates/variants/go-connectrpc/gen/chat/v1/chatv1connect/chat.connect.go +571 -0
  76. package/templates/variants/go-connectrpc/go.mod +4 -0
  77. package/templates/variants/go-connectrpc/internal/app/service.go +763 -71
  78. package/templates/variants/go-connectrpc/internal/config/config.go +22 -7
  79. package/templates/variants/go-connectrpc/internal/connectapi/handler.go +254 -42
  80. package/templates/variants/go-connectrpc/internal/connectapi/list_messages_integration_test.go +216 -0
  81. package/templates/variants/go-connectrpc/internal/httpapi/routes.go +41 -56
  82. package/templates/variants/go-connectrpc/migrations/0000_init.sql +63 -0
  83. package/templates/variants/go-connectrpc/protos/chat/v1/chat.proto +232 -0
  84. package/templates/shared/.env.example +0 -10
  85. package/templates/variants/go-chi/gen/dns/v1/dns.pb.go +0 -623
  86. package/templates/variants/go-chi/gen/dns/v1/dnsv1connect/dns.connect.go +0 -192
  87. package/templates/variants/go-chi/internal/connectapi/handler.go +0 -79
  88. package/templates/variants/go-chi/protos/dns/v1/dns.proto +0 -58
  89. package/templates/variants/go-connectrpc/gen/dns/v1/dns.pb.go +0 -623
  90. package/templates/variants/go-connectrpc/gen/dns/v1/dnsv1connect/dns.connect.go +0 -192
  91. package/templates/variants/go-connectrpc/protos/dns/v1/dns.proto +0 -58
@@ -1,192 +0,0 @@
1
- // Code generated by protoc-gen-connect-go. DO NOT EDIT.
2
- //
3
- // Source: dns/v1/dns.proto
4
-
5
- package dnsv1connect
6
-
7
- import (
8
- connect "connectrpc.com/connect"
9
- context "context"
10
- errors "errors"
11
- v1 "{{MODULE_PATH}}/gen/dns/v1"
12
- http "net/http"
13
- strings "strings"
14
- )
15
-
16
- // This is a compile-time assertion to ensure that this generated file and the connect package are
17
- // compatible. If you get a compiler error that this constant is not defined, this code was
18
- // generated with a version of connect newer than the one compiled into your binary. You can fix the
19
- // problem by either regenerating this code with an older version of connect or updating the connect
20
- // version compiled into your binary.
21
- const _ = connect.IsAtLeastVersion1_13_0
22
-
23
- const (
24
- // DNSServiceName is the fully-qualified name of the DNSService service.
25
- DNSServiceName = "dns.v1.DNSService"
26
- )
27
-
28
- // These constants are the fully-qualified names of the RPCs defined in this package. They're
29
- // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
30
- //
31
- // Note that these are different from the fully-qualified method names used by
32
- // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
33
- // reflection-formatted method names, remove the leading slash and convert the remaining slash to a
34
- // period.
35
- const (
36
- // DNSServiceListRecordsProcedure is the fully-qualified name of the DNSService's ListRecords RPC.
37
- DNSServiceListRecordsProcedure = "/dns.v1.DNSService/ListRecords"
38
- // DNSServiceCreateRecordProcedure is the fully-qualified name of the DNSService's CreateRecord RPC.
39
- DNSServiceCreateRecordProcedure = "/dns.v1.DNSService/CreateRecord"
40
- // DNSServiceUpdateRecordProcedure is the fully-qualified name of the DNSService's UpdateRecord RPC.
41
- DNSServiceUpdateRecordProcedure = "/dns.v1.DNSService/UpdateRecord"
42
- // DNSServiceDeleteRecordProcedure is the fully-qualified name of the DNSService's DeleteRecord RPC.
43
- DNSServiceDeleteRecordProcedure = "/dns.v1.DNSService/DeleteRecord"
44
- )
45
-
46
- // DNSServiceClient is a client for the dns.v1.DNSService service.
47
- type DNSServiceClient interface {
48
- ListRecords(context.Context, *connect.Request[v1.ListRecordsRequest]) (*connect.Response[v1.ListRecordsResponse], error)
49
- CreateRecord(context.Context, *connect.Request[v1.CreateRecordRequest]) (*connect.Response[v1.CreateRecordResponse], error)
50
- UpdateRecord(context.Context, *connect.Request[v1.UpdateRecordRequest]) (*connect.Response[v1.UpdateRecordResponse], error)
51
- DeleteRecord(context.Context, *connect.Request[v1.DeleteRecordRequest]) (*connect.Response[v1.DeleteRecordResponse], error)
52
- }
53
-
54
- // NewDNSServiceClient constructs a client for the dns.v1.DNSService service. By default, it uses
55
- // the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
56
- // uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
57
- // connect.WithGRPCWeb() options.
58
- //
59
- // The URL supplied here should be the base URL for the Connect or gRPC server (for example,
60
- // http://api.acme.com or https://acme.com/grpc).
61
- func NewDNSServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) DNSServiceClient {
62
- baseURL = strings.TrimRight(baseURL, "/")
63
- dNSServiceMethods := v1.File_dns_v1_dns_proto.Services().ByName("DNSService").Methods()
64
- return &dNSServiceClient{
65
- listRecords: connect.NewClient[v1.ListRecordsRequest, v1.ListRecordsResponse](
66
- httpClient,
67
- baseURL+DNSServiceListRecordsProcedure,
68
- connect.WithSchema(dNSServiceMethods.ByName("ListRecords")),
69
- connect.WithClientOptions(opts...),
70
- ),
71
- createRecord: connect.NewClient[v1.CreateRecordRequest, v1.CreateRecordResponse](
72
- httpClient,
73
- baseURL+DNSServiceCreateRecordProcedure,
74
- connect.WithSchema(dNSServiceMethods.ByName("CreateRecord")),
75
- connect.WithClientOptions(opts...),
76
- ),
77
- updateRecord: connect.NewClient[v1.UpdateRecordRequest, v1.UpdateRecordResponse](
78
- httpClient,
79
- baseURL+DNSServiceUpdateRecordProcedure,
80
- connect.WithSchema(dNSServiceMethods.ByName("UpdateRecord")),
81
- connect.WithClientOptions(opts...),
82
- ),
83
- deleteRecord: connect.NewClient[v1.DeleteRecordRequest, v1.DeleteRecordResponse](
84
- httpClient,
85
- baseURL+DNSServiceDeleteRecordProcedure,
86
- connect.WithSchema(dNSServiceMethods.ByName("DeleteRecord")),
87
- connect.WithClientOptions(opts...),
88
- ),
89
- }
90
- }
91
-
92
- // dNSServiceClient implements DNSServiceClient.
93
- type dNSServiceClient struct {
94
- listRecords *connect.Client[v1.ListRecordsRequest, v1.ListRecordsResponse]
95
- createRecord *connect.Client[v1.CreateRecordRequest, v1.CreateRecordResponse]
96
- updateRecord *connect.Client[v1.UpdateRecordRequest, v1.UpdateRecordResponse]
97
- deleteRecord *connect.Client[v1.DeleteRecordRequest, v1.DeleteRecordResponse]
98
- }
99
-
100
- // ListRecords calls dns.v1.DNSService.ListRecords.
101
- func (c *dNSServiceClient) ListRecords(ctx context.Context, req *connect.Request[v1.ListRecordsRequest]) (*connect.Response[v1.ListRecordsResponse], error) {
102
- return c.listRecords.CallUnary(ctx, req)
103
- }
104
-
105
- // CreateRecord calls dns.v1.DNSService.CreateRecord.
106
- func (c *dNSServiceClient) CreateRecord(ctx context.Context, req *connect.Request[v1.CreateRecordRequest]) (*connect.Response[v1.CreateRecordResponse], error) {
107
- return c.createRecord.CallUnary(ctx, req)
108
- }
109
-
110
- // UpdateRecord calls dns.v1.DNSService.UpdateRecord.
111
- func (c *dNSServiceClient) UpdateRecord(ctx context.Context, req *connect.Request[v1.UpdateRecordRequest]) (*connect.Response[v1.UpdateRecordResponse], error) {
112
- return c.updateRecord.CallUnary(ctx, req)
113
- }
114
-
115
- // DeleteRecord calls dns.v1.DNSService.DeleteRecord.
116
- func (c *dNSServiceClient) DeleteRecord(ctx context.Context, req *connect.Request[v1.DeleteRecordRequest]) (*connect.Response[v1.DeleteRecordResponse], error) {
117
- return c.deleteRecord.CallUnary(ctx, req)
118
- }
119
-
120
- // DNSServiceHandler is an implementation of the dns.v1.DNSService service.
121
- type DNSServiceHandler interface {
122
- ListRecords(context.Context, *connect.Request[v1.ListRecordsRequest]) (*connect.Response[v1.ListRecordsResponse], error)
123
- CreateRecord(context.Context, *connect.Request[v1.CreateRecordRequest]) (*connect.Response[v1.CreateRecordResponse], error)
124
- UpdateRecord(context.Context, *connect.Request[v1.UpdateRecordRequest]) (*connect.Response[v1.UpdateRecordResponse], error)
125
- DeleteRecord(context.Context, *connect.Request[v1.DeleteRecordRequest]) (*connect.Response[v1.DeleteRecordResponse], error)
126
- }
127
-
128
- // NewDNSServiceHandler builds an HTTP handler from the service implementation. It returns the path
129
- // on which to mount the handler and the handler itself.
130
- //
131
- // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
132
- // and JSON codecs. They also support gzip compression.
133
- func NewDNSServiceHandler(svc DNSServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
134
- dNSServiceMethods := v1.File_dns_v1_dns_proto.Services().ByName("DNSService").Methods()
135
- dNSServiceListRecordsHandler := connect.NewUnaryHandler(
136
- DNSServiceListRecordsProcedure,
137
- svc.ListRecords,
138
- connect.WithSchema(dNSServiceMethods.ByName("ListRecords")),
139
- connect.WithHandlerOptions(opts...),
140
- )
141
- dNSServiceCreateRecordHandler := connect.NewUnaryHandler(
142
- DNSServiceCreateRecordProcedure,
143
- svc.CreateRecord,
144
- connect.WithSchema(dNSServiceMethods.ByName("CreateRecord")),
145
- connect.WithHandlerOptions(opts...),
146
- )
147
- dNSServiceUpdateRecordHandler := connect.NewUnaryHandler(
148
- DNSServiceUpdateRecordProcedure,
149
- svc.UpdateRecord,
150
- connect.WithSchema(dNSServiceMethods.ByName("UpdateRecord")),
151
- connect.WithHandlerOptions(opts...),
152
- )
153
- dNSServiceDeleteRecordHandler := connect.NewUnaryHandler(
154
- DNSServiceDeleteRecordProcedure,
155
- svc.DeleteRecord,
156
- connect.WithSchema(dNSServiceMethods.ByName("DeleteRecord")),
157
- connect.WithHandlerOptions(opts...),
158
- )
159
- return "/dns.v1.DNSService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
160
- switch r.URL.Path {
161
- case DNSServiceListRecordsProcedure:
162
- dNSServiceListRecordsHandler.ServeHTTP(w, r)
163
- case DNSServiceCreateRecordProcedure:
164
- dNSServiceCreateRecordHandler.ServeHTTP(w, r)
165
- case DNSServiceUpdateRecordProcedure:
166
- dNSServiceUpdateRecordHandler.ServeHTTP(w, r)
167
- case DNSServiceDeleteRecordProcedure:
168
- dNSServiceDeleteRecordHandler.ServeHTTP(w, r)
169
- default:
170
- http.NotFound(w, r)
171
- }
172
- })
173
- }
174
-
175
- // UnimplementedDNSServiceHandler returns CodeUnimplemented from all methods.
176
- type UnimplementedDNSServiceHandler struct{}
177
-
178
- func (UnimplementedDNSServiceHandler) ListRecords(context.Context, *connect.Request[v1.ListRecordsRequest]) (*connect.Response[v1.ListRecordsResponse], error) {
179
- return nil, connect.NewError(connect.CodeUnimplemented, errors.New("dns.v1.DNSService.ListRecords is not implemented"))
180
- }
181
-
182
- func (UnimplementedDNSServiceHandler) CreateRecord(context.Context, *connect.Request[v1.CreateRecordRequest]) (*connect.Response[v1.CreateRecordResponse], error) {
183
- return nil, connect.NewError(connect.CodeUnimplemented, errors.New("dns.v1.DNSService.CreateRecord is not implemented"))
184
- }
185
-
186
- func (UnimplementedDNSServiceHandler) UpdateRecord(context.Context, *connect.Request[v1.UpdateRecordRequest]) (*connect.Response[v1.UpdateRecordResponse], error) {
187
- return nil, connect.NewError(connect.CodeUnimplemented, errors.New("dns.v1.DNSService.UpdateRecord is not implemented"))
188
- }
189
-
190
- func (UnimplementedDNSServiceHandler) DeleteRecord(context.Context, *connect.Request[v1.DeleteRecordRequest]) (*connect.Response[v1.DeleteRecordResponse], error) {
191
- return nil, connect.NewError(connect.CodeUnimplemented, errors.New("dns.v1.DNSService.DeleteRecord is not implemented"))
192
- }
@@ -1,58 +0,0 @@
1
- syntax = "proto3";
2
-
3
- package dns.v1;
4
-
5
- option go_package = "{{MODULE_PATH}}/gen/dns/v1;dnsv1";
6
-
7
- service DNSService {
8
- rpc ListRecords(ListRecordsRequest) returns (ListRecordsResponse) {}
9
- rpc CreateRecord(CreateRecordRequest) returns (CreateRecordResponse) {}
10
- rpc UpdateRecord(UpdateRecordRequest) returns (UpdateRecordResponse) {}
11
- rpc DeleteRecord(DeleteRecordRequest) returns (DeleteRecordResponse) {}
12
- }
13
-
14
- message Record {
15
- string id = 1;
16
- string type = 2;
17
- string name = 3;
18
- string content = 4;
19
- int32 ttl = 5;
20
- bool proxied = 6;
21
- }
22
-
23
- message ListRecordsRequest {}
24
-
25
- message ListRecordsResponse {
26
- repeated Record records = 1;
27
- }
28
-
29
- message CreateRecordRequest {
30
- string type = 1;
31
- string name = 2;
32
- string content = 3;
33
- int32 ttl = 4;
34
- bool proxied = 5;
35
- }
36
-
37
- message CreateRecordResponse {
38
- Record record = 1;
39
- }
40
-
41
- message UpdateRecordRequest {
42
- string id = 1;
43
- string type = 2;
44
- string name = 3;
45
- string content = 4;
46
- int32 ttl = 5;
47
- bool proxied = 6;
48
- }
49
-
50
- message UpdateRecordResponse {
51
- Record record = 1;
52
- }
53
-
54
- message DeleteRecordRequest {
55
- string id = 1;
56
- }
57
-
58
- message DeleteRecordResponse {}