app.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. export const EMAILOCTOPUS_API_KEY = new sst.Secret("EMAILOCTOPUS_API_KEY")
  5. const ADMIN_SECRET = new sst.Secret("ADMIN_SECRET")
  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, GITHUB_APP_ID, GITHUB_APP_PRIVATE_KEY, ADMIN_SECRET],
  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" || $app.stage === "thdxr" ? "" : "v1",
  29. newTag: $app.stage === "production" || $app.stage === "thdxr" ? "" : "v1",
  30. //newSqliteClasses: ["SyncServer"],
  31. }
  32. },
  33. },
  34. })
  35. new sst.cloudflare.x.Astro("Web", {
  36. domain: "docs." + domain,
  37. path: "packages/web",
  38. environment: {
  39. // For astro config
  40. SST_STAGE: $app.stage,
  41. VITE_API_URL: api.url.apply((url) => url!),
  42. },
  43. })
  44. new sst.cloudflare.StaticSite("WebApp", {
  45. domain: "app." + domain,
  46. path: "packages/app",
  47. build: {
  48. command: "bun turbo build",
  49. output: "./dist",
  50. },
  51. })