mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 13:05:09 +00:00
feat: 类型规范
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import { OB11EmitEventContent } from './index';
|
||||
import { Request, Response } from 'express';
|
||||
import { OB11Response } from '@/onebot/action/OneBotAction';
|
||||
import { OB11HttpServerAdapter } from './http-server';
|
||||
|
||||
export class OB11HttpSSEServerAdapter extends OB11HttpServerAdapter {
|
||||
private sseClients: Response[] = [];
|
||||
|
||||
async handleRequest(req: Request, res: Response): Promise<any> {
|
||||
override async handleRequest(req: Request, res: Response): Promise<any> {
|
||||
if (req.path === '/_events') {
|
||||
return this.createSseSupport(req, res);
|
||||
} else {
|
||||
@@ -26,7 +25,7 @@ export class OB11HttpSSEServerAdapter extends OB11HttpServerAdapter {
|
||||
});
|
||||
}
|
||||
|
||||
onEvent<T extends OB11EmitEventContent>(event: T) {
|
||||
override onEvent<T extends OB11EmitEventContent>(event: T) {
|
||||
this.sseClients.forEach((res) => {
|
||||
res.write(`data: ${JSON.stringify(event)}\n\n`);
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ export class OB11HttpServerAdapter extends IOB11NetworkAdapter<HttpServerConfig>
|
||||
super(name, config, core, obContext, actions);
|
||||
}
|
||||
|
||||
onEvent<T extends OB11EmitEventContent>(event: T) {
|
||||
onEvent<T extends OB11EmitEventContent>(_event: T) {
|
||||
// http server is passive, no need to emit event
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ export class OB11HttpServerAdapter extends IOB11NetworkAdapter<HttpServerConfig>
|
||||
return res.status(400).send('Invalid JSON');
|
||||
}
|
||||
});
|
||||
req.on('error', (err) => {
|
||||
req.on('error', (_err) => {
|
||||
return res.status(400).send('Invalid JSON');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user