app.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 DISCORD_SUPPORT_BOT_TOKEN = new sst.Secret("DISCORD_SUPPORT_BOT_TOKEN")
  7. const DISCORD_SUPPORT_CHANNEL_ID = new sst.Secret("DISCORD_SUPPORT_CHANNEL_ID")
  8. const FEISHU_APP_ID = new sst.Secret("FEISHU_APP_ID")
  9. const FEISHU_APP_SECRET = new sst.Secret("FEISHU_APP_SECRET")
  10. const bucket = new sst.cloudflare.Bucket("Bucket")
  11. export const api = new sst.cloudflare.Worker("Api", {
  12. domain: `api.${domain}`,
  13. handler: "packages/function/src/api.ts",
  14. environment: {
  15. WEB_DOMAIN: domain,
  16. },
  17. url: true,
  18. link: [
  19. bucket,
  20. GITHUB_APP_ID,
  21. GITHUB_APP_PRIVATE_KEY,
  22. ADMIN_SECRET,
  23. DISCORD_SUPPORT_BOT_TOKEN,
  24. DISCORD_SUPPORT_CHANNEL_ID,
  25. FEISHU_APP_ID,
  26. FEISHU_APP_SECRET,
  27. ],
  28. transform: {
  29. worker: (args) => {
  30. args.logpush = true
  31. if ($app.stage === "vimtor" || $app.stage === "adam") return
  32. args.bindings = $resolve(args.bindings).apply((bindings) => [
  33. ...bindings,
  34. {
  35. name: "SYNC_SERVER",
  36. type: "durable_object_namespace",
  37. className: "SyncServer",
  38. },
  39. ])
  40. args.migrations = {
  41. // Note: when releasing the next tag, make sure all stages use tag v2
  42. oldTag: $app.stage === "production" || $app.stage === "thdxr" ? "" : "v1",
  43. newTag: $app.stage === "production" || $app.stage === "thdxr" ? "" : "v1",
  44. //newSqliteClasses: ["SyncServer"],
  45. }
  46. },
  47. },
  48. })
  49. new sst.cloudflare.x.Astro("Web", {
  50. domain: "docs." + domain,
  51. path: "packages/web",
  52. environment: {
  53. // For astro config
  54. SST_STAGE: $app.stage,
  55. VITE_API_URL: api.url.apply((url) => url!),
  56. },
  57. })
  58. new sst.cloudflare.StaticSite("WebApp", {
  59. domain: "app." + domain,
  60. path: "packages/app",
  61. build: {
  62. command: "bun turbo build",
  63. output: "./dist",
  64. },
  65. })