1
0

config.prod.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import { EggAppConfig, PowerPartial } from 'egg';
  2. export default () => {
  3. const config: PowerPartial<EggAppConfig> = {};
  4. /**
  5. * https://github.com/puppeteer/puppeteer
  6. */
  7. config.puppeteer = {
  8. launchOptions: {
  9. args: [ '--no-sandbox', '--disable-setuid-sandbox' ],
  10. executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
  11. ignoreHTTPSErrors: true,
  12. },
  13. };
  14. /**
  15. * 邮件推送配置
  16. */
  17. config.mailer = {
  18. host: 'xxxxxxxx',
  19. port: 25,
  20. user: 'xxxx',
  21. pass: 'xxxx',
  22. secure: false,
  23. };
  24. /**
  25. * 七牛配置
  26. */
  27. config.qiniu = {
  28. accessKey: 'xxxxx',
  29. secretKey: 'xxxx',
  30. bucket: 'xxxx',
  31. cdnUrl: 'xxxx',
  32. zone: 'xxx',
  33. };
  34. // bull config
  35. config.bull = {
  36. default: {
  37. redis: {
  38. port: 6379,
  39. host: '127.0.0.1',
  40. password: '123456',
  41. db: 0,
  42. },
  43. prefix: 'admin:task',
  44. },
  45. };
  46. /**
  47. * typeorm 配置
  48. * 文档:https://www.npmjs.com/package/egg-ts-typeorm
  49. */
  50. config.typeorm = {
  51. client: {
  52. type: 'mysql',
  53. host: '127.0.0.1',
  54. port: 3306,
  55. username: 'root',
  56. password: 'xdh192358',
  57. database: 'tgbot',
  58. synchronize: false,
  59. logging: true,
  60. // timezone: '+08:00',
  61. /**
  62. * JavaScript对数据库中int和bigint的区别对待:
  63. * 刚开始开发中,线下测试数据库id字段采用int,数据库SELECT操作返回的结果是Number,但是使用bigint,数据库返回的为String,
  64. * 初步猜想是因为bigint的值范围会超过Number,所以采用String。但是这样会对我们业务产生巨大影戏那个,一方面,DTO校验会无法通过,另一方面,问题1中的业务逻辑会受影响。
  65. * 经过查找各方文档,解决方案是在数据库连接配置中配置:
  66. * "supportBigNumbers": false
  67. * 可以配置这个的原因是我们的业务ID距离Number的上线远远达不到,所以可以用这种方式让
  68. * bigint也返回Number。
  69. * 但是这样配置,TypeOrm插入操作的返回值中的identifiers字段中的id还是String,所以问题1中的处理方式也要对String进行parseInt操作。
  70. */
  71. supportBigNumbers: false,
  72. },
  73. };
  74. /**
  75. * redis 配置
  76. * https://github.com/eggjs/egg-redis
  77. */
  78. config.redis = {
  79. Redis: require('ioredis'),
  80. clients: {
  81. // instanceName. See below
  82. admin: {
  83. port: 6379,
  84. host: '127.0.0.1',
  85. password: '',
  86. db: 0,
  87. },
  88. app: {
  89. port: 6379,
  90. host: '127.0.0.1',
  91. password: '',
  92. db: 1,
  93. },
  94. },
  95. };
  96. return config;
  97. };