mirror of
https://github.com/Chanzhaoyu/chatgpt-web.git
synced 2025-07-21 11:57:47 +00:00
23 lines
531 B
TypeScript
23 lines
531 B
TypeScript
interface SendResponseOptions {
|
|
type: 'success' | 'fail'
|
|
message?: string
|
|
data?: any
|
|
}
|
|
|
|
export function sendResponse(options: SendResponseOptions) {
|
|
if (options.type === 'success') {
|
|
return Promise.resolve({
|
|
message: options.message ?? 'Success',
|
|
data: options.data ?? null,
|
|
status: options.type,
|
|
})
|
|
}
|
|
|
|
// eslint-disable-next-line prefer-promise-reject-errors
|
|
return Promise.reject({
|
|
message: options.message ?? 'Failed',
|
|
data: options.data ?? null,
|
|
status: options.type,
|
|
})
|
|
}
|