app.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. args.bindings = $resolve(args.bindings).apply((bindings) => [
  32. ...bindings,
  33. {
  34. name: "SYNC_SERVER",
  35. type: "durable_object_namespace",
  36. className: "SyncServer",
  37. },
  38. ])
  39. args.migrations = {
  40. // Note: when releasing the next tag, make sure all stages use tag v2
  41. oldTag: $app.stage === "production" || $app.stage === "thdxr" ? "" : "v1",
  42. newTag: $app.stage === "production" || $app.stage === "thdxr" ? "" : "v1",
  43. //newSqliteClasses: ["SyncServer"],
  44. }
  45. },
  46. },
  47. })
  48. new sst.cloudflare.x.Astro("Web", {
  49. domain: "docs." + domain,
  50. path: "packages/web",
  51. environment: {
  52. // For astro config
  53. SST_STAGE: $app.stage,
  54. VITE_API_URL: api.url.apply((url) => url!),
  55. },
  56. })
  57. new sst.cloudflare.StaticSite("WebApp", {
  58. domain: "app." + domain,
  59. path: "packages/app",
  60. build: {
  61. command: "bun turbo build",
  62. output: "./dist",
  63. },
  64. })