app.ts 1.2 KB

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