app.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. export const domain = (() => {
  2. if ($app.stage === "production") return "opencode.ai"
  3. if ($app.stage === "dev") return "dev.opencode.ai"
  4. return `${$app.stage}.dev.opencode.ai`
  5. })()
  6. const GITHUB_APP_ID = new sst.Secret("GITHUB_APP_ID")
  7. const GITHUB_APP_PRIVATE_KEY = new sst.Secret("GITHUB_APP_PRIVATE_KEY")
  8. const bucket = new sst.cloudflare.Bucket("Bucket")
  9. export const api = new sst.cloudflare.Worker("Api", {
  10. domain: `api.${domain}`,
  11. handler: "packages/function/src/api.ts",
  12. environment: {
  13. WEB_DOMAIN: domain,
  14. },
  15. url: true,
  16. link: [bucket, GITHUB_APP_ID, GITHUB_APP_PRIVATE_KEY],
  17. transform: {
  18. worker: (args) => {
  19. args.logpush = true
  20. args.bindings = $resolve(args.bindings).apply((bindings) => [
  21. ...bindings,
  22. {
  23. name: "SYNC_SERVER",
  24. type: "durable_object_namespace",
  25. className: "SyncServer",
  26. },
  27. ])
  28. args.migrations = {
  29. // Note: when releasing the next tag, make sure all stages use tag v2
  30. oldTag: $app.stage === "production" ? "" : "v1",
  31. newTag: $app.stage === "production" ? "" : "v1",
  32. //newSqliteClasses: ["SyncServer"],
  33. }
  34. },
  35. },
  36. })
  37. new sst.cloudflare.x.Astro("Web", {
  38. domain,
  39. path: "packages/web",
  40. environment: {
  41. // For astro config
  42. SST_STAGE: $app.stage,
  43. VITE_API_URL: api.url,
  44. },
  45. })