From 5f31c1c4130f70ae3c1032e1b60095066111db29 Mon Sep 17 00:00:00 2001 From: xudafeng Date: Sun, 14 Aug 2022 11:21:50 +0800 Subject: [PATCH] feat: tweak default config --- config/config.default.js | 196 +++++++++++++++++++-------------------- 1 file changed, 97 insertions(+), 99 deletions(-) diff --git a/config/config.default.js b/config/config.default.js index 62b3ead..64e5f89 100644 --- a/config/config.default.js +++ b/config/config.default.js @@ -3,103 +3,101 @@ const path = require('path'); const dbConfig = require('../database/config'); -module.exports = appInfo => { - const config = exports = {}; - - config.siteFile = { - '/favicon.ico': 'https://macacajs.github.io/assets/favicon.ico', - }; - - // use for cookie sign key, should change to your own and keep security - config.keys = process.env.RELIABLE_SECRET_KEY || appInfo.name + '_1528180445670_8068'; - - // add your config here - config.middleware = [ - 'forbidden', - 'hostRedirect', - 'openApiAuthorize', - 'authorize', - 'inject', - 'cors', - 'errorHandler', - ]; - - config.hostRedirect = { - enable: !!process.env.RELIABLE_DEFAULT_HOST, - defaultHost: process.env.RELIABLE_DEFAULT_HOST, - ignore: [ - /^\/api\//, - ], - }; - - config.authorize = { - enable: process.env.RELIABLE_ENABLE_AUTHORIZE === 'Y', - ignore: [ - '/snsAuthorize/callback/dingtalk', - '/snsAuthorize/auth', - '/snsAuthorize/signout', - - '/api/gw', - '/api/latestBuild/:id', - '/api/app/:id', - '/api/build/:id', - ], - dingtalkAuth: { - appid: process.env.RELIABLE_AUTH_DINGTALK_APPID, - appsecret: process.env.RELIABLE_AUTH_DINGTALK_APPSECRET, - callbackUrl: '/snsAuthorize/callback/dingtalk', - }, - }; - - config.openApiAuthorize = { - enable: process.env.RELIABLE_ENABLE_OPENAPI_AUTHORIZE === 'Y', - match: [ - '/api/gw', - '/api/latestBuild/:id', - '/api/app/:id', - '/api/build/:id', - ], - }; - - config.session = { - maxAge: 48 * 3600 * 1000, // 48 hours - renew: true, // keep session - }; - - config.modelQueryConfig = { - pagination: { - // default num - num: 10, - }, - }; - - config.errorHandler = { - match: '/api', - }; - - const reliableHost = process.env.RELIABLE_HOST || '127.0.0.1'; - - config.reliableView = { - serverUrl: '', - reliableHost, - }; - - config.security = { - csrf: { - enable: false, - }, - methodnoallow: { - enable: false, - }, - }; - - config.sequelize = dbConfig.development; - - const distDirName = 'dist'; - config.static = { - prefix: `/${distDirName}/`, - dir: path.resolve(__dirname, '..', 'view', distDirName), - }; - - return config; +const config = {}; + +config.siteFile = { + '/favicon.ico': 'https://macacajs.github.io/assets/favicon.ico', +}; + +// use for cookie sign key, should change to your own and keep security +config.keys = (process.env.RELIABLE_SECRET_KEY || 'reliable') + '_1528180445670_8068'; + +// add your config here +config.middleware = [ + 'forbidden', + 'hostRedirect', + 'openApiAuthorize', + 'authorize', + 'inject', + 'cors', + 'errorHandler', +]; + +config.hostRedirect = { + enable: !!process.env.RELIABLE_DEFAULT_HOST, + defaultHost: process.env.RELIABLE_DEFAULT_HOST, + ignore: [ + /^\/api\//, + ], +}; + +config.authorize = { + enable: process.env.RELIABLE_ENABLE_AUTHORIZE === 'Y', + ignore: [ + '/snsAuthorize/callback/dingtalk', + '/snsAuthorize/auth', + '/snsAuthorize/signout', + + '/api/gw', + '/api/latestBuild/:id', + '/api/app/:id', + '/api/build/:id', + ], + dingtalkAuth: { + appid: process.env.RELIABLE_AUTH_DINGTALK_APPID, + appsecret: process.env.RELIABLE_AUTH_DINGTALK_APPSECRET, + callbackUrl: '/snsAuthorize/callback/dingtalk', + }, +}; + +config.openApiAuthorize = { + enable: process.env.RELIABLE_ENABLE_OPENAPI_AUTHORIZE === 'Y', + match: [ + '/api/gw', + '/api/latestBuild/:id', + '/api/app/:id', + '/api/build/:id', + ], +}; + +config.session = { + maxAge: 48 * 3600 * 1000, // 48 hours + renew: true, // keep session +}; + +config.modelQueryConfig = { + pagination: { + // default num + num: 10, + }, }; + +config.errorHandler = { + match: '/api', +}; + +const reliableHost = process.env.RELIABLE_HOST || '127.0.0.1'; + +config.reliableView = { + serverUrl: '', + reliableHost, +}; + +config.security = { + csrf: { + enable: false, + }, + methodnoallow: { + enable: false, + }, +}; + +config.sequelize = dbConfig.development; + +const distDirName = 'dist'; +config.static = { + prefix: `/${distDirName}/`, + dir: path.resolve(__dirname, '..', 'view', distDirName), +}; + +module.exports = config;