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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { expect, test } from "bun:test";
|
|
2
2
|
import { createApp } from "../src/index";
|
|
3
|
-
import type {
|
|
3
|
+
import type { WaitlistService } from "../src/waitlist/service";
|
|
4
|
+
import type { WaitlistEntry } from "../src/waitlist/types";
|
|
4
5
|
|
|
5
6
|
test("health endpoint returns ok", async () => {
|
|
6
7
|
const response = await createApp(createMockService()).request("/healthz");
|
|
@@ -14,53 +15,83 @@ test("webhook health endpoint returns ok", async () => {
|
|
|
14
15
|
expect(await response.json()).toEqual({ status: "ok", provider: "generic" });
|
|
15
16
|
});
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
throw new Error("not implemented");
|
|
30
|
-
},
|
|
31
|
-
async getConversation() {
|
|
32
|
-
throw new Error("not implemented");
|
|
33
|
-
},
|
|
34
|
-
async updateConversation() {
|
|
35
|
-
throw new Error("not implemented");
|
|
36
|
-
},
|
|
37
|
-
async deleteConversation() {},
|
|
38
|
-
async addParticipant() {
|
|
39
|
-
throw new Error("not implemented");
|
|
18
|
+
test("waitlist join returns created entry", async () => {
|
|
19
|
+
const response = await createApp(createMockService()).request("/v1/waitlist", {
|
|
20
|
+
method: "POST",
|
|
21
|
+
headers: { "Content-Type": "application/json" },
|
|
22
|
+
body: JSON.stringify({ email: "founder@example.com", source: "test" }),
|
|
23
|
+
});
|
|
24
|
+
expect(response.status).toBe(201);
|
|
25
|
+
expect(await response.json()).toMatchObject({
|
|
26
|
+
created: true,
|
|
27
|
+
entry: {
|
|
28
|
+
email: "founder@example.com",
|
|
29
|
+
status: "joined",
|
|
40
30
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("waitlist api requires a bearer token when service auth is enabled", async () => {
|
|
35
|
+
const previous = Bun.env.AUTH_ENABLED;
|
|
36
|
+
Bun.env.AUTH_ENABLED = "true";
|
|
37
|
+
try {
|
|
38
|
+
const response = await createApp(createMockService()).request("/v1/waitlist", {
|
|
39
|
+
method: "POST",
|
|
40
|
+
headers: { "Content-Type": "application/json" },
|
|
41
|
+
body: JSON.stringify({ email: "founder@example.com" }),
|
|
42
|
+
});
|
|
43
|
+
expect(response.status).toBe(401);
|
|
44
|
+
expect(await response.json()).toEqual({ error: "missing bearer token", code: "unauthorized" });
|
|
45
|
+
} finally {
|
|
46
|
+
if (previous === undefined) {
|
|
47
|
+
delete Bun.env.AUTH_ENABLED;
|
|
48
|
+
} else {
|
|
49
|
+
Bun.env.AUTH_ENABLED = previous;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
function createMockService(): WaitlistService {
|
|
55
|
+
const entry: WaitlistEntry = {
|
|
56
|
+
id: "entry_1",
|
|
57
|
+
email: "founder@example.com",
|
|
58
|
+
name: null,
|
|
59
|
+
company: null,
|
|
60
|
+
source: "test",
|
|
61
|
+
status: "joined",
|
|
62
|
+
createdAt: "2026-01-01T00:00:00.000Z",
|
|
63
|
+
updatedAt: "2026-01-01T00:00:00.000Z",
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
async joinWaitlist() {
|
|
68
|
+
return { entry, created: true };
|
|
44
69
|
},
|
|
45
|
-
async
|
|
46
|
-
|
|
70
|
+
async getWaitlistEntry() {
|
|
71
|
+
return entry;
|
|
47
72
|
},
|
|
48
|
-
async
|
|
49
|
-
|
|
73
|
+
async getWaitlistEntryByEmail() {
|
|
74
|
+
return entry;
|
|
50
75
|
},
|
|
51
|
-
async
|
|
52
|
-
|
|
53
|
-
throw new Error("not implemented");
|
|
76
|
+
async listWaitlistEntries() {
|
|
77
|
+
return [entry];
|
|
54
78
|
},
|
|
55
|
-
async
|
|
56
|
-
|
|
79
|
+
async updateWaitlistEntry() {
|
|
80
|
+
return { ...entry, status: "invited" };
|
|
57
81
|
},
|
|
58
|
-
async
|
|
59
|
-
|
|
82
|
+
async exportWaitlistEntries() {
|
|
83
|
+
return "id,email,name,company,source,status,created_at,updated_at\nentry_1,founder@example.com,,,test,joined,2026-01-01T00:00:00.000Z,2026-01-01T00:00:00.000Z";
|
|
60
84
|
},
|
|
61
|
-
async
|
|
62
|
-
|
|
63
|
-
|
|
85
|
+
async recordTrigger() {
|
|
86
|
+
return {
|
|
87
|
+
id: "trigger_1",
|
|
88
|
+
type: "manual",
|
|
89
|
+
entryId: null,
|
|
90
|
+
status: "queued",
|
|
91
|
+
payload: {},
|
|
92
|
+
createdAt: "2026-01-01T00:00:00.000Z",
|
|
93
|
+
processedAt: null,
|
|
94
|
+
};
|
|
64
95
|
},
|
|
65
96
|
};
|
|
66
97
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { afterEach, beforeEach, expect, test } from "bun:test";
|
|
2
|
+
import { SQL } from "bun";
|
|
3
|
+
import { createApp } from "../src/index";
|
|
4
|
+
import { DefaultWaitlistService } from "../src/waitlist/service";
|
|
5
|
+
import { WaitlistRepository } from "../src/db/repository";
|
|
6
|
+
import { createDb } from "../src/db/client";
|
|
7
|
+
|
|
8
|
+
const databaseUrl = Bun.env.DATABASE_URL?.trim();
|
|
9
|
+
const integrationTest = databaseUrl ? test : test.skip;
|
|
10
|
+
|
|
11
|
+
let sql: SQL | null = null;
|
|
12
|
+
|
|
13
|
+
beforeEach(async () => {
|
|
14
|
+
if (!databaseUrl) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
sql = new SQL(databaseUrl);
|
|
18
|
+
await sql.unsafe(`
|
|
19
|
+
truncate table
|
|
20
|
+
waitlist_triggers,
|
|
21
|
+
waitlist_entries
|
|
22
|
+
restart identity cascade
|
|
23
|
+
`);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
afterEach(async () => {
|
|
27
|
+
await sql?.end();
|
|
28
|
+
sql = null;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
integrationTest("waitlist join is idempotent and records triggers", async () => {
|
|
32
|
+
const app = createApp(new DefaultWaitlistService(new WaitlistRepository(createDb(databaseUrl))));
|
|
33
|
+
|
|
34
|
+
const first = await requestJson(app, "/v1/waitlist", {
|
|
35
|
+
method: "POST",
|
|
36
|
+
body: {
|
|
37
|
+
email: "Founder@Example.com",
|
|
38
|
+
name: "Founder",
|
|
39
|
+
company: "Example Co",
|
|
40
|
+
source: "homepage",
|
|
41
|
+
},
|
|
42
|
+
expectedStatus: 201,
|
|
43
|
+
});
|
|
44
|
+
expect(first.entry.email).toBe("founder@example.com");
|
|
45
|
+
expect(first.created).toBe(true);
|
|
46
|
+
|
|
47
|
+
const second = await requestJson(app, "/v1/waitlist", {
|
|
48
|
+
method: "POST",
|
|
49
|
+
body: {
|
|
50
|
+
email: "founder@example.com",
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
expect(second.entry.id).toBe(first.entry.id);
|
|
54
|
+
expect(second.created).toBe(false);
|
|
55
|
+
|
|
56
|
+
const trigger = await requestJson(app, "/v1/triggers/waitlist", {
|
|
57
|
+
method: "POST",
|
|
58
|
+
body: {
|
|
59
|
+
type: "cron.digest",
|
|
60
|
+
entry_id: first.entry.id,
|
|
61
|
+
},
|
|
62
|
+
expectedStatus: 202,
|
|
63
|
+
});
|
|
64
|
+
expect(trigger.trigger).toMatchObject({
|
|
65
|
+
type: "cron.digest",
|
|
66
|
+
entryId: first.entry.id,
|
|
67
|
+
status: "queued",
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const updated = await requestJson(app, `/v1/admin/waitlist/${first.entry.id}`, {
|
|
71
|
+
method: "PATCH",
|
|
72
|
+
body: { status: "invited" },
|
|
73
|
+
});
|
|
74
|
+
expect(updated.entry).toMatchObject({ id: first.entry.id, status: "invited" });
|
|
75
|
+
|
|
76
|
+
const list = await requestJson(app, "/v1/admin/waitlist?status=invited");
|
|
77
|
+
expect(list.entries).toHaveLength(1);
|
|
78
|
+
expect(list.entries[0]).toMatchObject({ id: first.entry.id, status: "invited" });
|
|
79
|
+
|
|
80
|
+
const exportResponse = await app.request("/v1/admin/waitlist/export?status=invited");
|
|
81
|
+
expect(exportResponse.status).toBe(200);
|
|
82
|
+
expect(exportResponse.headers.get("content-type")).toContain("text/csv");
|
|
83
|
+
expect(await exportResponse.text()).toContain("founder@example.com");
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
async function requestJson(
|
|
87
|
+
app: ReturnType<typeof createApp>,
|
|
88
|
+
path: string,
|
|
89
|
+
input: {
|
|
90
|
+
method?: string;
|
|
91
|
+
body?: unknown;
|
|
92
|
+
expectedStatus?: number;
|
|
93
|
+
} = {}
|
|
94
|
+
) {
|
|
95
|
+
const response = await app.request(path, {
|
|
96
|
+
method: input.method ?? "GET",
|
|
97
|
+
headers: input.body ? { "Content-Type": "application/json" } : undefined,
|
|
98
|
+
body: input.body ? JSON.stringify(input.body) : undefined,
|
|
99
|
+
});
|
|
100
|
+
expect(response.status).toBe(input.expectedStatus ?? 200);
|
|
101
|
+
return response.json();
|
|
102
|
+
}
|
|
@@ -1,29 +1,45 @@
|
|
|
1
|
-
.PHONY: dev migrate gen lint test
|
|
1
|
+
.PHONY: dev migrate migrate-lint gen lint test create deploy dashboards auth destroy
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
SERVICE := npx --no-install service
|
|
4
4
|
WITH_ENV := set -a; [ ! -f .env.local ] || . ./.env.local; set +a;
|
|
5
|
+
ATLAS ?= atlas
|
|
5
6
|
|
|
6
7
|
dev:
|
|
7
|
-
|
|
8
|
+
@bun run ./scripts/dev.ts go run ./cmd/server
|
|
8
9
|
|
|
9
10
|
migrate:
|
|
10
|
-
|
|
11
|
+
@bun run ./scripts/ensure-local-db.ts
|
|
12
|
+
@bun run ./scripts/wait-for-db.ts
|
|
13
|
+
@$(WITH_ENV) $(ATLAS) migrate apply --env local
|
|
14
|
+
|
|
15
|
+
migrate-lint:
|
|
16
|
+
@bun run ./scripts/ensure-local-db.ts
|
|
17
|
+
@bun run ./scripts/wait-for-db.ts
|
|
18
|
+
@$(WITH_ENV) $(ATLAS) migrate lint --env local --latest 1
|
|
11
19
|
|
|
12
20
|
gen:
|
|
13
|
-
|
|
21
|
+
@echo "no generated code for go + chi"
|
|
14
22
|
|
|
15
23
|
lint:
|
|
16
24
|
go vet ./...
|
|
17
|
-
|
|
25
|
+
@bun run ./scripts/ensure-local-db.ts
|
|
26
|
+
@bun run ./scripts/wait-for-db.ts
|
|
27
|
+
@$(WITH_ENV) $(ATLAS) migrate lint --env local --latest 1
|
|
18
28
|
|
|
19
29
|
test:
|
|
20
30
|
bun test ./test
|
|
21
31
|
|
|
22
|
-
|
|
23
|
-
$(
|
|
32
|
+
create:
|
|
33
|
+
$(SERVICE) create
|
|
24
34
|
|
|
25
35
|
deploy:
|
|
26
|
-
$(
|
|
36
|
+
$(SERVICE) deploy $(ARGS)
|
|
37
|
+
|
|
38
|
+
dashboards:
|
|
39
|
+
$(SERVICE) dashboards
|
|
40
|
+
|
|
41
|
+
auth:
|
|
42
|
+
$(SERVICE) auth $(ARGS)
|
|
27
43
|
|
|
28
|
-
|
|
29
|
-
$(
|
|
44
|
+
destroy:
|
|
45
|
+
$(SERVICE) destroy $(ARGS)
|
|
@@ -6,15 +6,16 @@ import (
|
|
|
6
6
|
"net/http"
|
|
7
7
|
"time"
|
|
8
8
|
|
|
9
|
-
"cloud.google.com/go/storage"
|
|
10
9
|
"github.com/go-chi/chi/v5"
|
|
11
10
|
_ "github.com/jackc/pgx/v5/stdlib"
|
|
12
11
|
"golang.org/x/net/http2"
|
|
13
12
|
"golang.org/x/net/http2/h2c"
|
|
14
13
|
|
|
15
14
|
"{{MODULE_PATH}}/internal/app"
|
|
15
|
+
"{{MODULE_PATH}}/internal/auth"
|
|
16
16
|
"{{MODULE_PATH}}/internal/config"
|
|
17
17
|
"{{MODULE_PATH}}/internal/httpapi"
|
|
18
|
+
temporalapp "{{MODULE_PATH}}/internal/temporal"
|
|
18
19
|
)
|
|
19
20
|
|
|
20
21
|
func main() {
|
|
@@ -28,18 +29,28 @@ func main() {
|
|
|
28
29
|
log.Fatal(err)
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
if
|
|
33
|
-
|
|
32
|
+
service := app.NewWaitlistService(db)
|
|
33
|
+
if cfg.TemporalEnabled {
|
|
34
|
+
stopTemporal, err := temporalapp.StartWorker(temporalapp.WorkerConfig{
|
|
35
|
+
Address: cfg.TemporalAddress,
|
|
36
|
+
Namespace: cfg.TemporalNamespace,
|
|
37
|
+
TaskQueue: cfg.TemporalTaskQueue,
|
|
38
|
+
APIKey: cfg.TemporalAPIKey,
|
|
39
|
+
})
|
|
40
|
+
if err != nil {
|
|
41
|
+
log.Fatal(err)
|
|
42
|
+
}
|
|
43
|
+
defer stopTemporal()
|
|
44
|
+
log.Printf("Temporal worker polling %s", cfg.TemporalTaskQueue)
|
|
34
45
|
}
|
|
35
46
|
|
|
36
|
-
service := app.NewChatService(
|
|
37
|
-
db,
|
|
38
|
-
app.NewGCSStorage(cfg.AttachmentBucket, cfg.AttachmentPublicBaseURL, storageClient),
|
|
39
|
-
app.GenericWebhookAdapter{},
|
|
40
|
-
)
|
|
41
|
-
|
|
42
47
|
router := chi.NewRouter()
|
|
48
|
+
router.Use(auth.Middleware(auth.Config{
|
|
49
|
+
Enabled: cfg.AuthEnabled,
|
|
50
|
+
Issuer: cfg.AuthIssuer,
|
|
51
|
+
Audience: cfg.AuthAudience,
|
|
52
|
+
JWKSURL: cfg.AuthJWKSURL,
|
|
53
|
+
}))
|
|
43
54
|
httpapi.RegisterRoutes(router, service)
|
|
44
55
|
|
|
45
56
|
server := &http.Server{
|
|
@@ -3,11 +3,9 @@ module {{MODULE_PATH}}
|
|
|
3
3
|
go 1.25.4
|
|
4
4
|
|
|
5
5
|
require (
|
|
6
|
-
cloud.google.com/go/storage v1.53.0
|
|
7
|
-
connectrpc.com/connect v1.19.1
|
|
8
6
|
github.com/go-chi/chi/v5 v5.2.2
|
|
9
7
|
github.com/jackc/pgx/v5 v5.7.5
|
|
10
8
|
github.com/jmoiron/sqlx v1.4.0
|
|
9
|
+
go.temporal.io/sdk v1.43.0
|
|
11
10
|
golang.org/x/net v0.42.0
|
|
12
|
-
google.golang.org/protobuf v1.36.10
|
|
13
11
|
)
|