Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hangjob/egg-bag-framework
🍁基于Egg.js封装框架,扩展常用模块jwt、令牌桶、参数校验、加解密,多文件上传等等,开箱即用
https://github.com/hangjob/egg-bag-framework
eggjs mysql nodejs redis
Last synced: about 9 hours ago
JSON representation
🍁基于Egg.js封装框架,扩展常用模块jwt、令牌桶、参数校验、加解密,多文件上传等等,开箱即用
- Host: GitHub
- URL: https://github.com/hangjob/egg-bag-framework
- Owner: hangjob
- Created: 2023-10-12T08:51:37.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-15T10:40:39.000Z (about 1 year ago)
- Last Synced: 2024-12-16T03:07:43.502Z (about 1 month ago)
- Topics: eggjs, mysql, nodejs, redis
- Language: JavaScript
- Homepage:
- Size: 370 KB
- Stars: 15
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# egg-bag-framework
🍁基于Egg.js封装框架,扩展常用模块jwt、令牌桶、参数校验、加解密,多文件上传等等,开箱即用
该框架,面向于企业中的后端程序,代码下载下来后,自行更改mysql、redis配置
## 开始
```bash
$ npm install
```## 创建软连接
```bash
$ npm link
$ npm link egg-bag-framework // 应用目录
```## 应用项目部署-服务器
将应用部署到服务器上,`app`,`config`,`package.json`,`app.js`
```json
{
"start": "egg-scripts start --daemon --port=7010 --title=egg-bag"
}
```
```bash
npm install
npm run start # npm run stop 如果有先暂停项目以免端口占用
# 会一生成一个守护进程 http://127.0.0.1:7010/
```
## nginx
添加一个反向代理到 http://127.0.0.1:7010/
```nignx
location ^~ /
{
proxy_pass http://127.0.0.1:3010/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1;
add_header X-Cache $upstream_cache_status;
if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" )
{
expires 30d;
}
proxy_ignore_headers Set-Cookie Cache-Control expires;
proxy_cache cache_one;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 304 301 302 10m;
}
```## 附带功能
### 前端压缩视频
大文件放到前端压缩,会很好的减轻服务器的压力
```html视频前端压缩
const { createFFmpeg, fetchFile } = FFmpeg;
const text = document.getElementById('text');
const ffmpeg = createFFmpeg({
log: true,
progress: ({ ratio }) => {
text.innerHTML = `完成率: ${(ratio * 100.0).toFixed(2)}%`;
},
});
const transcode = async ({ target: { files } }) => {
const { name } = files[0];
text.innerHTML = '正在加载 ffmpeg-core.js';
await ffmpeg.load();
text.innerHTML = '开始压缩';
ffmpeg.FS('writeFile', name, await fetchFile(files[0]));
// '-b','2000000' 值越小 压缩率越大
await ffmpeg.run('-i', name, '-b', '2000000', 'put.mp4');
text.innerHTML = '压缩完成';
const data = ffmpeg.FS('readFile', 'put.mp4');
const video = document.getElementById('video');
video.src = URL.createObjectURL(new Blob([ data.buffer ], {
type: 'video/mp4'
}));
};
document.getElementById('upload').addEventListener('change', transcode);```
### 帮助文档
https://juejin.cn/post/7288178532862083112
https://www.kancloud.cn/han88829/book/2025973### 数据库
https://blog.csdn.net/ab15176142633/article/details/120064660