app.ts 1.1 KB

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