mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-11 18:10:32 +08:00
✨ Feature(server): add http server for uploading images by a http request
port 37766
This commit is contained in:
19
src/main/server/utils.ts
Normal file
19
src/main/server/utils.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
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()
|
||||
}
|
||||
Reference in New Issue
Block a user