opencode_offline/infra/app.ts

45 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-08-09 01:22:54 +08:00
import { domain } from "./stage"
2025-05-24 03:57:33 +08:00
const GITHUB_APP_ID = new sst.Secret("GITHUB_APP_ID")
const GITHUB_APP_PRIVATE_KEY = new sst.Secret("GITHUB_APP_PRIVATE_KEY")
2025-05-24 02:17:45 +08:00
const bucket = new sst.cloudflare.Bucket("Bucket")
export const api = new sst.cloudflare.Worker("Api", {
2025-05-24 03:57:33 +08:00
domain: `api.${domain}`,
2025-05-24 02:17:45 +08:00
handler: "packages/function/src/api.ts",
2025-07-03 21:58:25 +08:00
environment: {
WEB_DOMAIN: domain,
},
2025-05-24 02:17:45 +08:00
url: true,
link: [bucket, GITHUB_APP_ID, GITHUB_APP_PRIVATE_KEY],
2025-05-24 02:17:45 +08:00
transform: {
worker: (args) => {
2025-05-31 02:40:53 +08:00
args.logpush = true
2025-05-24 02:17:45 +08:00
args.bindings = $resolve(args.bindings).apply((bindings) => [
...bindings,
{
name: "SYNC_SERVER",
type: "durable_object_namespace",
className: "SyncServer",
},
])
args.migrations = {
2025-06-20 05:20:13 +08:00
// Note: when releasing the next tag, make sure all stages use tag v2
oldTag: $app.stage === "production" ? "" : "v1",
newTag: $app.stage === "production" ? "" : "v1",
//newSqliteClasses: ["SyncServer"],
2025-05-24 02:17:45 +08:00
}
},
},
})
2025-08-09 01:22:54 +08:00
export const web = new sst.cloudflare.x.Astro("Web", {
2025-05-24 03:57:33 +08:00
domain,
2025-06-06 03:37:17 +08:00
path: "packages/web",
2025-05-24 02:40:28 +08:00
environment: {
2025-07-08 04:31:10 +08:00
// For astro config
2025-07-08 04:25:39 +08:00
SST_STAGE: $app.stage,
2025-08-09 01:22:54 +08:00
VITE_API_URL: api.url.apply((url) => url!),
2025-05-24 02:40:28 +08:00
},
})