Skip to content

Commit

Permalink
chore: enhance config (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
xudafeng authored Aug 16, 2022
1 parent 0318080 commit c058c1c
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 111 deletions.
226 changes: 115 additions & 111 deletions config/config.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,115 +3,119 @@
const path = require('path');
const dbConfig = require('../database/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',
// eslint-disable-next-line no-unused-vars
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 || '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),
};

config.site = {
logo: 'https://macacajs.github.io/reliable/logo/reliable.svg',
name: 'Reliable',
links: {
document: 'https://macacajs.github.io/reliable',
issues: 'https://github.com/macacajs/reliable/issues?utf8=%E2%9C%93&q=',
},
};

config.admin = {
userKey: '',
list: [],
};

// inject-extra-config
return config;
};

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),
};

config.site = {
logo: 'https://macacajs.github.io/reliable/logo/reliable.svg',
name: 'Reliable',
links: {
document: 'https://macacajs.github.io/reliable',
issues: 'https://github.com/macacajs/reliable/issues?utf8=%E2%9C%93&q=',
},
};

config.admin = {
userKey: '',
list: [],
};

module.exports = config;
8 changes: 8 additions & 0 deletions config/config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@

const dbConfig = require('../database/config');
exports.sequelize = dbConfig.production;

// eslint-disable-next-line no-unused-vars
module.exports = appInfo => {
const config = exports = {};

// inject-extra-config
return config;
};

0 comments on commit c058c1c

Please sign in to comment.