Advanced Config
支持通过环境变量配置应用:
export APP_DEBUG=trueexport APP_PORT=3000export APP_SECRET=your-secret-key创建 config.json:
{ "server": { "host": "0.0.0.0", "port": 3000 }, "database": { "url": "mongodb://localhost:27017", "name": "myapp" }, "cache": { "enabled": true, "ttl": 3600 }}config/├── default.json├── development.json├── production.json└── test.jsonimport { createLogger } from 'my-awesome-lib'
const logger = createLogger({ level: 'debug', format: 'json', output: './logs/app.log'})- 启用缓存
- 使用连接池
- 开启 gzip 压缩
- 配置 CDN