更新依赖项,优化 WebSocket 处理,添加文件流管道功能,改进用户认证逻辑
This commit is contained in:
19
src/modules/fm-manager/pipe.ts
Normal file
19
src/modules/fm-manager/pipe.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import * as http from 'http';
|
||||
import * as fs from 'fs';
|
||||
import { isBun } from '../../utils/get-engine.ts';
|
||||
|
||||
export const pipeFileStream = (filePath: string, res: http.ServerResponse) => {
|
||||
const readStream = fs.createReadStream(filePath);
|
||||
if (isBun) {
|
||||
res.pipe(readStream as any);
|
||||
} else {
|
||||
readStream.pipe(res, { end: true });
|
||||
}
|
||||
}
|
||||
export const pipeStream = (readStream: fs.ReadStream, res: http.ServerResponse) => {
|
||||
if (isBun) {
|
||||
res.pipe(readStream as any);
|
||||
} else {
|
||||
readStream.pipe(res, { end: true });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user