config.default.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* eslint valid-jsdoc: "off" */
  2. 'use strict';
  3. /**
  4. * @param {Egg.EggAppInfo} appInfo app info
  5. */
  6. const ip = '192.168.1.197';
  7. const branch = 'Two';
  8. const branchRouter = 'two';
  9. const port = 12312;
  10. const dbName = `shopping${branch}`;
  11. const redisPwd = '';
  12. const redisDB = 3;
  13. const mqUser = `shopping${branch}`;
  14. const routePrefix = `/dev/point/${branchRouter}/zr/v1/api`;
  15. const email_smsConfig = `shopping${branch}`;
  16. const appSign = `shopping${branch}`;
  17. const { jwt } = require('./config.secret');
  18. module.exports = (appInfo) => {
  19. /**
  20. * built-in config
  21. * @type {Egg.EggAppConfig}
  22. **/
  23. const config = (exports = {});
  24. // use for cookie sign key, should change to your own and keep security
  25. config.keys = appInfo.name + '_1666686710616_3993';
  26. config.appName = '商城-服务';
  27. // add your middleware config here
  28. config.middleware = ['setUserFromToken'];
  29. config.checkToken = {
  30. enable: false,
  31. };
  32. // 进程设置
  33. config.cluster = {
  34. listen: {
  35. port: port,
  36. },
  37. };
  38. // 数据库设置
  39. config.mongoose = {
  40. url: `mongodb://${ip}:27017/${dbName}`, // 120.48.146.1 127.0.0.1
  41. options: {
  42. user: 'admin',
  43. pass: 'admin',
  44. authSource: 'admin',
  45. useNewUrlParser: true,
  46. useCreateIndex: true,
  47. useFindAndModify: true,
  48. allowDiskUse: true,
  49. },
  50. };
  51. // redis设置
  52. config.redis = {
  53. client: {
  54. port: 6379, // Redis port
  55. host: ip, // Redis host
  56. password: redisPwd,
  57. db: redisDB,
  58. },
  59. };
  60. // mq设置
  61. config.amqp = {
  62. client: {
  63. hostname: ip,
  64. username: mqUser,
  65. password: mqUser,
  66. vhost: mqUser,
  67. },
  68. app: true,
  69. agent: true,
  70. };
  71. // jwt设置
  72. config.jwt = {
  73. ...jwt,
  74. expiresIn: '1d',
  75. issuer: 'shopping',
  76. };
  77. // 路由设置
  78. config.routePrefix = routePrefix;
  79. config.emailConfig = {
  80. config: email_smsConfig,
  81. };
  82. config.smsConfig = {
  83. config: email_smsConfig,
  84. };
  85. // 中间件
  86. config.requestLog = {
  87. toMongoDB: true,
  88. };
  89. config.redisKey = {
  90. orderKeyPrefix: 'zrOrderKey:',
  91. };
  92. config.redisTimeout = 3600;
  93. config.wxPayConfig = appSign;
  94. // add your user config here
  95. const userConfig = {
  96. // myAppName: 'egg',
  97. };
  98. return {
  99. ...config,
  100. ...userConfig,
  101. };
  102. };