config.default.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /* eslint valid-jsdoc: "off" */
  2. 'use strict';
  3. /**
  4. * @param {Egg.EggAppInfo} appInfo app info
  5. */
  6. module.exports = appInfo => {
  7. const config = exports = {};
  8. // use for cookie sign key, should change to your own and keep security
  9. config.keys = appInfo.name + '_1560223608734_7978';
  10. // post form请求 关闭csrf安全插件
  11. config.security = {
  12. csrf: {
  13. enable: false,
  14. ignoreJSON: true,
  15. },
  16. // domainWhiteList: [ 'http://www.baidu.com' ], // 配置白名单
  17. };
  18. // 配置上传
  19. config.multipart = {
  20. fileSize: '50mb',
  21. mode: 'stream',
  22. fileExtensions: [ '.jpg', '.img', '.png', '.docx' ], // 扩展几种上传的文件格式
  23. };
  24. // add your middleware config here
  25. config.middleware = [ 'common', 'interceptor', 'xml2js' ];
  26. config.interceptor = {
  27. ignore(ctx) {
  28. // 所有微信的接口 和 登录接口不需要带用户
  29. const ignoreUrl = [
  30. '/index',
  31. '/sys/login/in',
  32. '/wx/wxMessage',
  33. '/wx/getSign',
  34. '/wx/getOpenId',
  35. '/wx/getAppId',
  36. '/wxinfo/isExist',
  37. '/wxinfo/bing',
  38. '/wxinfo/visitIsExist',
  39. '/wxinfo/visitBing',
  40. '/wxinfo/visitUnbind',
  41. '/wxinfo/visitByFid',
  42. '/wxinfo/visitByNumber',
  43. '/visit/one',
  44. '/applet/isExist',
  45. '/applet/bing',
  46. '/applet/homeStatistics',
  47. '/welcomeMessage/list',
  48. '/banner/list',
  49. '/wx/getAppletOpenId',
  50. '/applet/appletVisitIsExist',
  51. '/applet/appletVisitBing',
  52. '/applet/appletVisitUnbind',
  53. ];
  54. const url = ctx.request.url;
  55. for (const item of ignoreUrl) {
  56. if (url.indexOf(item) >= 0) {
  57. return true;
  58. }
  59. }
  60. return false;
  61. },
  62. };
  63. config.xml2js = {
  64. match(ctx) {
  65. const matchUrl = [ '/wx/wxMessage' ];
  66. const url = ctx.request.url;
  67. for (const item of matchUrl) {
  68. if (url.indexOf(item) >= 0) {
  69. return true;
  70. }
  71. }
  72. return false;
  73. },
  74. };
  75. config.common = {
  76. match() {
  77. return true;
  78. },
  79. };
  80. config.wechat_config = {
  81. // 这边使用的是故事机的appId 后期无解
  82. appId: 'wx22055631b887c2ab',
  83. appSecret: '328614e5d0d0b5f90c8480a6a9f81b00',
  84. getAccessToken: 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET',
  85. createMenu: 'https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN',
  86. getUserInfo: 'https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN',
  87. getJsApiTicket: 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=jsapi',
  88. // 公众号获取openid
  89. oauthAccessToken: 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code',
  90. // 小程序获取openid
  91. getAppletAccessToken: 'https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=CODE&grant_type=authorization_code',
  92. oauthUserinfo: 'https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN',
  93. };
  94. // 加密
  95. config.dump = { ignore: new Set([
  96. 'pass', 'pwd', 'passd', 'passwd', 'password', 'keys', 'masterKey', 'accessKey',
  97. // ignore any key contains "secret" keyword
  98. /secret/i, 'wechat_config', 'userConfig',
  99. ]) };
  100. // add your user config here
  101. const userConfig = {
  102. // myAppName: 'egg',
  103. cors: {
  104. origin: '*', // 注释掉就是上面的white生效
  105. allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
  106. },
  107. mongoose: {
  108. // url: 'mongodb://127.0.0.1/info0303', // 本地
  109. url: 'mongodb://infotest:infotest@172.17.222.95:27018/info_test',
  110. // url: 'mongodb://user_infoadmin:123456@39.105.97.139:27018/info_admin',
  111. // url: 'mongodb://infoadmin:infoadmin@39.105.97.139/info_admin', // 正式-info_admin表用户
  112. options: {
  113. useUnifiedTopology: true,
  114. },
  115. },
  116. redis: {
  117. client: {
  118. port: 6379, // Redis port
  119. host: '39.105.97.139', // Redis host
  120. password: '',
  121. db: 0,
  122. },
  123. },
  124. sessionTimeOut: 86400, // 24H
  125. defaultPassword: '123456',
  126. defaultPageSize: 10,
  127. defaultUploadPath: '/strong/images/info_admin/',
  128. // defaultUploadPath: './app/public/uploads/',
  129. defaultWritePathPre: '/public/uploads/',
  130. // defaultUrl: 'https://info.windd.cn/collection',
  131. // defaultUrl: 'http://info.windd.cn:8080/test',
  132. defaultUrl: 'https://info.windd.cn/test',
  133. weiXinUrl: 'https://info.windd.cn/infoVue/#/visit/',
  134. defaultAdminId: '5d0070438217f92210e6f972',
  135. defaultAdminRoleId: '5d030a91ebd90c299489c121',
  136. defaultManagerRoleId: '5d036441464ced1f1840204a',
  137. defaultUserRoleId: '5d0c41046a0a730a44fe06b5',
  138. logger: {
  139. consoleLevel: 'DEBUG', // NONE
  140. allowDebugAtProd: true,
  141. // level: 'DEBUG', // NONE
  142. },
  143. };
  144. return {
  145. ...config,
  146. ...userConfig,
  147. };
  148. };