Skip to content

Commit

Permalink
feat: tweak default config
Browse files Browse the repository at this point in the history
  • Loading branch information
xudafeng committed Aug 14, 2022
1 parent b9ac487 commit 5f31c1c
Showing 1 changed file with 97 additions and 99 deletions.
196 changes: 97 additions & 99 deletions config/config.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 5f31c1c

Please sign in to comment.