123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- /* eslint valid-jsdoc: 'off' */
- 'use strict';
- /**
- * @param {Egg.EggAppInfo} appInfo app info
- */
- const path = require('path');
- const { sep } = require('path');
- module.exports = appInfo => {
- /**
- * built-in config
- * @type {Egg.EggAppConfig}
- **/
- const config = exports = {};
- // use for cookie sign key, should change to your own and keep security
- config.keys = appInfo.name + '_1636338746694_9710';
- // add your middleware config here
- config.middleware = [];
- // add your user config here
- const userConfig = {
- // myAppName: 'egg',
- };
- // 安全配置
- config.security = {
- csrf: {
- // ignoreJSON: true, // 默认为 false,当设置为 true 时,将会放过所有 content-type 为 `application/json` 的请求
- enable: false,
- },
- };
- config.cluster = {
- listen: {
- port: 18093,
- },
- };
- // 数据库配置
- config.mongoose = {
- // url: 'mongodb://127.0.0.1:27018/Microservices',
- url: 'mongodb://172.17.116.7:27018/Microservices',
- options: {
- user: 'root',
- pass: 'cms@cc-lotus',
- authSource: 'admin',
- useNewUrlParser: true,
- useCreateIndex: true,
- },
- };
- // 文件存储路径
- config.repos_root_path = `${appInfo.baseDir}${sep}upload`;
- config.root_path = `${appInfo.baseDir}`;
- // 是否启用持久化数据
- config.data_save = true;
- // 限制文件大小
- config.multipart = {
- mode: 'stream',
- fileSize: '5mb',
- fileExtensions: [ '.rtf', '.csv', '.odp', '.csv', '.ods', '.pptx', '.ppt', '.rar', '.7z', '.tar', '.gz', '.tar', '.gz', '.zip', '.doc', '.docx', '.xlsx', '.xls', '.jpg', '.jpeg', '.png', '.gif', '.bmp', '.svg', '.tiff', '.pdf', '.txt', '.mp4', '.avi', '.mov', '.wmv', '.flv', '.mkv', '.m4v' ], // 新增允许接收的文件后缀
- // whitelist: [], // 覆盖允许接收的文件后缀
- };
- config.logger = {
- level: 'DEBUG',
- };
- config.static = {
- // 静态化访问前缀,如:`http://127.0.0.1:7001/static/images/logo.png`
- prefix: '/upload',
- dir: path.join(appInfo.baseDir, 'upload'), // `String` or `Array:[dir1, dir2, ...]` 静态化目录,可以设置多个静态化目录
- dynamic: true, // 如果当前访问的静态资源没有缓存,则缓存静态文件,和`preload`配合使用;
- preload: false,
- maxAge: 31536000, // in prod env, 0 in other envs
- buffer: true, // in prod env, false in other envs
- };
- return {
- ...config,
- ...userConfig,
- };
- };
|