ChelesteWang / FE-Review

前端知识复盘与整理
Apache License 2.0
33 stars 8 forks source link

Nodejs 后端开发杂谈 #18

Open ChelesteWang opened 3 years ago

ChelesteWang commented 3 years ago

不应在 Application 中开启 gzip

在大业务量的生产环境网站中,强烈推荐将压缩功能从应用服务器中卸载——典型做法是使用反向代理(例如 Nginx)。在这种情况下,你不应该使用压缩中间件。

建议使用 nginx 进行部署

ChelesteWang commented 3 years ago

node 性能优化

3 nodejs 服务端部署资源利用问题

2 Nodejs 并发测试

ChelesteWang commented 3 years ago

dotenv配置与使用

$ npm install dotenv --save-dev

使用 config

const envConfig = dotenv.config({
    path: path.resolve(__dirname, '../.env'), // 配置文件路径
    encoding: 'utf8', // 编码方式,默认utf8
    debug: false, // 是否开启debug,默认false
}).parsed;

if (!envConfig) {
    console.log('配置文件不存在');
    // 退出程序
    process.exit(1);
}
ChelesteWang commented 3 years ago

Mock 服务方案

使用 Json-server 模拟后端

https://github.com/typicode/json-server

使用 service worker 模拟后端

https://github.com/mswjs/msw

ChelesteWang commented 2 years ago

nodejs 底层原理 https://mp.weixin.qq.com/s/aEWdYiu7WWtchSw4G0vhRQ