omnics / apps /server /src /common /interceptors /transform.interceptor.ts
OpenClaw AI
feat(ocr): implement screen recognition prototype with Tesseract.js and Electron IPC
7b7e57d
Raw History Blame Contribute Delete
721 Bytes
import {
Injectable,
NestInterceptor,
ExecutionContext,
CallHandler,
} from '@nestjs/common';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
export interface Response<T> {
data: T;
statusCode: number;
message: string;
}
@Injectable()
export class TransformInterceptor<T>
implements NestInterceptor<T, Response<T>> {
intercept(
context: ExecutionContext,
next: CallHandler,
): Observable<Response<T>> {
return next.handle().pipe(
map((data) => ({
data,
statusCode: context.switchToHttp().getResponse().statusCode,
message: 'success',
})),
);
}
}