mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-01-25 23:48:13 -05:00
20 lines
349 B
TypeScript
20 lines
349 B
TypeScript
|
export const handleResponse = ({
|
||
|
response,
|
||
|
statusCode = 200,
|
||
|
header = {
|
||
|
'Content-Type': 'application/json'
|
||
|
},
|
||
|
body = {
|
||
|
success: false
|
||
|
}
|
||
|
} : {
|
||
|
response: IHttpResponse,
|
||
|
statusCode?: number,
|
||
|
header?: IObj,
|
||
|
body?: any
|
||
|
}) => {
|
||
|
response.writeHead(statusCode, header)
|
||
|
response.write(JSON.stringify(body))
|
||
|
response.end()
|
||
|
}
|