企业微信智能机器人API插件

This commit is contained in:
2026-09-03 21:29:10 +08:00
parent ec9b7efcd6
commit 418e13a5e3
22 changed files with 1154 additions and 33 deletions
@@ -6,10 +6,19 @@ import {
} from '@nestjs/common';
import { Observable, map } from 'rxjs';
function skipResponseWrap(url?: string): boolean {
const path = (url || '').split('?')[0];
return path.endsWith('/wecom/plugin/openapi.json');
}
@Injectable()
export class ResponseInterceptor implements NestInterceptor {
intercept(context: ExecutionContext, next: CallHandler): Observable<unknown> {
const req = context.switchToHttp().getRequest<{ originalUrl?: string; url?: string }>();
const res = context.switchToHttp().getResponse<{ headersSent?: boolean }>();
if (skipResponseWrap(req.originalUrl || req.url)) {
return next.handle();
}
return next.handle().pipe(
map((data) => {
if (res.headersSent) return data;
@@ -22,3 +31,4 @@ export class ResponseInterceptor implements NestInterceptor {
);
}
}