mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-05-16 01:12:46 +00:00
refactor: bare structure for new backend architecture and runtime; no behavior changes yet
This commit is contained in:
36
server/src/shared/http/api-response.ts
Normal file
36
server/src/shared/http/api-response.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import type { ApiErrorShape, ApiMeta, ApiSuccessShape } from '../types/http.js';
|
||||
|
||||
export function createApiMeta(requestId?: string, startedAt?: string): ApiMeta {
|
||||
return {
|
||||
requestId,
|
||||
startedAt,
|
||||
};
|
||||
}
|
||||
|
||||
export function createApiSuccessResponse<TData>(
|
||||
data: TData,
|
||||
meta?: ApiMeta
|
||||
): ApiSuccessShape<TData> {
|
||||
return {
|
||||
success: true,
|
||||
data,
|
||||
meta,
|
||||
};
|
||||
}
|
||||
|
||||
export function createApiErrorResponse(
|
||||
code: string,
|
||||
message: string,
|
||||
meta?: ApiMeta,
|
||||
details?: unknown
|
||||
): ApiErrorShape {
|
||||
return {
|
||||
success: false,
|
||||
error: {
|
||||
code,
|
||||
message,
|
||||
details,
|
||||
},
|
||||
meta,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user