mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-03-01 08:10:25 +00:00
Changed import statements from alias-based paths (e.g., '@/napcat-common/store') to direct module references (e.g., 'napcat-common/src/store') in Proxy.ts, Status.ts, Data.ts, and SignToken.ts for improved compatibility and clarity.
20 lines
703 B
TypeScript
20 lines
703 B
TypeScript
import { RequestHandler } from 'express';
|
|
import { SystemStatus, statusHelperSubscription } from 'napcat-core/helper/status';
|
|
|
|
export const StatusRealTimeHandler: RequestHandler = async (req, res) => {
|
|
res.setHeader('Content-Type', 'text/event-stream');
|
|
res.setHeader('Connection', 'keep-alive');
|
|
const sendStatus = (status: SystemStatus) => {
|
|
try {
|
|
res.write(`data: ${JSON.stringify(status)}\n\n`);
|
|
} catch (e) {
|
|
console.error(`An error occurred when writing sendStatus data to client: ${e}`);
|
|
}
|
|
};
|
|
statusHelperSubscription.on('statusUpdate', sendStatus);
|
|
req.on('close', () => {
|
|
statusHelperSubscription.off('statusUpdate', sendStatus);
|
|
res.end();
|
|
});
|
|
};
|