style: styled code

This commit is contained in:
원더 2021-01-05 10:30:54 +09:00
parent 9a3826753d
commit 0d3efd3c79
5 changed files with 20 additions and 17 deletions

View File

@ -1,6 +1,9 @@
import http from 'http' import http from 'http'
import { NextApiResponse } from 'next' import { NextApiResponse } from 'next'
export default function ResponseWrapper(res: NextApiResponse, { code, message, version=2, data, errors }:ResponseProps) { export default function ResponseWrapper(
res: NextApiResponse,
{ code, message, version = 2, data, errors }: ResponseProps
) {
if (!code) throw new Error('`code` is required.') if (!code) throw new Error('`code` is required.')
if (!http.STATUS_CODES[code]) throw new Error('Invalid http code.') if (!http.STATUS_CODES[code]) throw new Error('Invalid http code.')
res.statusCode = code res.statusCode = code