Feature(server): add http server for uploading images by a http request

port 37766
This commit is contained in:
Molunerfinn
2019-12-31 23:50:19 +08:00
parent 3fd95725cf
commit c56d4efa79
13 changed files with 558 additions and 54 deletions

19
src/main/server/utils.ts Normal file
View 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()
}