feat: 搭建 NestJS 后端基础设施与 Prisma 数据模型

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Nixevol
2026-06-28 15:35:47 +08:00
co-authored by Cursor
parent 3e9ab08881
commit 9629597b1d
23 changed files with 8051 additions and 0 deletions
@@ -0,0 +1,25 @@
import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiResponse } from '@artveris/shared';
// 将控制器返回值统一包裹为 { code, message, data }。
@Injectable()
export class TransformInterceptor<T> implements NestInterceptor<T, ApiResponse<T>> {
intercept(_context: ExecutionContext, next: CallHandler<T>): Observable<ApiResponse<T>> {
return next.handle().pipe(
map((data) => {
if (
data &&
typeof data === 'object' &&
'code' in (data as object) &&
'message' in (data as object) &&
'data' in (data as object)
) {
return data as unknown as ApiResponse<T>;
}
return { code: 0, message: 'success', data: (data ?? null) as T | null };
}),
);
}
}