fastify.d.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import 'fastify'
  2. import { DataSource } from 'typeorm'
  3. import Redis from 'ioredis'
  4. import { BannerStatisticsScheduler } from '../scheduler/banner-statistics.scheduler'
  5. declare module 'fastify' {
  6. interface FastifyInstance {
  7. config: {
  8. NODE_ENV: string
  9. PORT: number
  10. HOST: string
  11. JWT_SECRET: string
  12. JWT_EXPIRES_IN: string
  13. DB_HOST: string
  14. DB_PORT: string
  15. DB_USERNAME: string
  16. DB_PASSWORD: string
  17. DB_DATABASE: string
  18. // OSS配置
  19. OSS_KEY: string
  20. OSS_SECRET: string
  21. OSS_BUCKET: string
  22. OSS_REGION: string
  23. OSS_ENDPOINT: string
  24. // 文件上传配置
  25. UPLOAD_FOLDER: string
  26. // 支付配置
  27. PAYMENT_URL: string
  28. PAYMENT_KEY: string
  29. PAYMENT_PID: string
  30. // Redis配置(可选)
  31. REDIS_HOST?: string
  32. REDIS_PORT?: number
  33. REDIS_PASSWORD?: string
  34. REDIS_DB?: number
  35. // 视频API配置(可选)
  36. VIDEO_API_URL?: string
  37. }
  38. dataSource: DataSource
  39. redis?: Redis
  40. bannerStatisticsScheduler?: BannerStatisticsScheduler
  41. }
  42. interface FastifyRequest {
  43. file(): Promise<{
  44. filename: string
  45. mimetype: string
  46. toBuffer(): Promise<Buffer>
  47. } | null>
  48. user?: {
  49. id: number
  50. name: string
  51. role: string
  52. iat?: number
  53. }
  54. }
  55. }