app.ts 1.2 KB

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