config.prod.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. 'use strict';
  2. // 生产配置
  3. /**
  4. * @param {Egg.EggAppInfo} appInfo app info
  5. */
  6. const ip = 'host.docker.internal';
  7. const branch = 'Two';
  8. const branchRouter = 'two';
  9. const port = 12311;
  10. const dbName = `shopping${branch}`;
  11. const redisPwd = '123456';
  12. const redisDB = 3;
  13. const mqUser = `shopping${branch}`;
  14. const routePrefix = `/point/${branchRouter}/v1/api`;
  15. const payReturn = `https://broadcast.waityou24.cn/point/${branchRouter}/v1/api/pay/order`;
  16. const email_smsConfig = `shopping${branch}`;
  17. const appSign = `shopping${branch}`;
  18. const { jwt } = require('./config.secret');
  19. module.exports = (appInfo) => {
  20. /**
  21. * built-in config
  22. * @type {Egg.EggAppConfig}
  23. **/
  24. const config = (exports = {});
  25. // use for cookie sign key, should change to your own and keep security
  26. config.keys = appInfo.name + '_1664237342649_2194';
  27. config.appName = '商城-服务';
  28. // add your middleware config here
  29. config.middleware = ['errorEmail', 'setUserFromToken', 'checkLogin', 'checkUserRK']; // , 'checkLogin'
  30. // add your user config here
  31. const userConfig = {
  32. // myAppName: 'egg',
  33. };
  34. config.checkToken = {
  35. enable: false,
  36. };
  37. // 进程设置
  38. config.cluster = {
  39. listen: {
  40. port: port,
  41. },
  42. };
  43. // 数据库设置
  44. config.mongoose = {
  45. url: `mongodb://${ip}:27017/${dbName}`, // 120.48.146.1 127.0.0.1
  46. options: {
  47. user: 'admin',
  48. pass: 'admin',
  49. authSource: 'admin',
  50. useNewUrlParser: true,
  51. useCreateIndex: true,
  52. useFindAndModify: true,
  53. allowDiskUse: true,
  54. },
  55. };
  56. // jwt设置
  57. config.jwt = {
  58. ...jwt,
  59. expiresIn: '1d',
  60. issuer: 'shopping',
  61. };
  62. // redis设置
  63. config.redis = {
  64. client: {
  65. port: 6379, // Redis port
  66. host: ip, // Redis host
  67. password: redisPwd,
  68. db: redisDB,
  69. },
  70. };
  71. // mq设置
  72. config.amqp = {
  73. client: {
  74. hostname: ip,
  75. username: mqUser,
  76. password: mqUser,
  77. vhost: mqUser,
  78. },
  79. app: true,
  80. agent: true,
  81. };
  82. // 定时任务机制设置
  83. config.taskMqConfig = {
  84. ex: `task${branch}`,
  85. queue: `task${branch}`,
  86. routingKey: `tr${branch}`,
  87. deadEx: `deadTask${branch}`,
  88. deadQueue: `deadTaskQueue${branch}`,
  89. deadLetterRoutingKey: `deadTr${branch}`,
  90. };
  91. config.msgEx = `t_m_${branch}`;
  92. // 路由设置
  93. config.routePrefix = routePrefix;
  94. // 支付路由回调设置
  95. config.payReturn = {
  96. order: payReturn,
  97. };
  98. // http请求前缀
  99. config.httpPrefix = {
  100. wechat: 'https://broadcast.waityou24.cn/wechat/api',
  101. email: 'http://127.0.0.1:14002/semail/api',
  102. sms: 'http://127.0.0.1:14003/sms/api',
  103. };
  104. config.emailConfig = {
  105. config: email_smsConfig,
  106. };
  107. config.smsConfig = {
  108. config: email_smsConfig,
  109. };
  110. // 中间件
  111. config.requestLog = {
  112. toMongoDB: true,
  113. };
  114. config.redisKey = {
  115. orderKeyPrefix: 'orderKey:',
  116. };
  117. config.redisTimeout = 3600;
  118. config.errcode = {
  119. groupJoinRefund: -111,
  120. };
  121. config.wxPayConfig = appSign;
  122. config.logger = {
  123. level: 'NONE',
  124. };
  125. config.projects = ['group-service', 'service-point_shop']; // 协作项目:团购服务,尊荣服务
  126. return {
  127. ...config,
  128. ...userConfig,
  129. };
  130. };