Files
bamboo/config/config.js
T
robin a593253a63 up
2022-04-05 02:52:41 +08:00

110 lines
4.1 KiB
JavaScript

'use strict';
module.exports = {
keys: '',
listen: {
port: 32006,
host: '0.0.0.0',
},
// 配置需要的中间件,数组顺序即为中间件的加载顺序
middleware: ['jiujianJwt'],
mysql: {
host: '192.168.1.25',
port: 3306,
username: 'shichu',
password: 'zXbAhBA26anGGEhY',
},
mongo: {},
redis: {
path: '',
port: 32005,
hostname: '0.0.0.0',
},
sequelize: {},
/** 关闭csrf,否则api post将无法访问 */
csrf: false,
jwt: {
secret: "_shichu",//自定义 token 的加密条件字符串
expiresIn: "30d",//表示有效期 不带单位默认为秒 如带单位如: "2 days", "10h", "7d"
},
/** cors 允许跨域 */
cors: {
origin: '*',
credentials: true,
allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
},
/** multipart 文件上传 */
multipart: {
whitelist: [// 文件白名单
// images
'.jpg', '.jpeg', // image/jpeg
'.png', // image/png, image/x-png
// '.gif', // image/gif
// '.bmp', // image/bmp
// '.wbmp', // image/vnd.wap.wbmp
// '.webp',
// '.tif',
// '.psd',
// // text
// '.svg',
// '.js', '.jsx',
// '.json',
// '.css', '.less',
// '.html', '.htm',
// '.xml',
// // tar
// '.zip',
// '.gz', '.tgz', '.gzip',
// // video
// '.mp3',
// '.mp4',
// '.avi',
'.p12',
],
},
axios: {
// can set more config in headers,like token,references and so on
headers: {
common: {
'Content-Type': 'application/json; charset=UTF-8',
// 添加认证【例如】,也可以在请求拦截器中修改具体的request config
// 'Authorization':'19980115_520' // 不要问我19980115是什么,当然是女朋友生日呀!!!
},
// 可以设置请求头等属性
},
// 定义请求拦截器处理方法【可选】
// requestInterceptorsHandler: config => {
// console.log('定义请求拦截器处理方法',config);
// 请求之前的配置信息
// 当该字段【函数】不存在是,默认如下:
// app.coreLogger.debug(`[egg-axios-plus] send request, baseURL: ${JSON.stringify(baseURL)}, url: ${url}, method: ${method}, data: ${JSON.stringify(data)}, headers: ${JSON.stringify(headers)}`);
// return config;
// },
// requestInterceptorsErrorHandler: error => {
// // 请求之后发生的错误信息
// // 当该字段【函数】不存在是,默认如下:
// app.coreLogger.error(`[egg-axios-plus] send request error, ${error.message}`);
// return Promise.reject(error);
// },
// // 定义axios响应拦截器处理方法【可选】
// responseInterceptorsHandler: response => {
// // response 响应结果
// // 当该字段【函数】不存在是,默认如下:
// app.coreLogger.debug(`[egg-axios-plus] receive response, data: ${JSON.stringify(response.data)}, status: ${response.status}, headers: ${JSON.stringify(response.headers)}`);
// if (response.config && (response.method.toUpperCase() === 'HEAD' || response.method.toUpperCase() === 'options')) {
// return response;
// }
// return response.data;
// },
responseInterceptorsErrorHandler: error => {
// 接口响应失败的错误结果
// 当该字段【函数】不存在是,默认如下:
// app.coreLogger.error(`[egg-axios-plus] receive response error, ${error.message}`);
console.log(`[egg-axios-plus] receive response error, ${error.message}`);
return Promise.reject(error);
},
timeout: 12000, // 默认请求超时
app: true, // 在app.js上启动加载
agent: false, // 在agent.js上启动加载
}
};