api articles typing fix

This commit is contained in:
tmshv committed 2019-10-21 15:24:14 +03:00
1 parent 5cbce648c4
commit 8c2b17150b
1 file changed
+7 -2
+7 -2
View File
@@ -1,10 +1,15 @@
import { findArticles } from '../../../src/server/articles'
import { withMiddleware } from '../../../src/middlewares/withMiddleware'
const int = (value: string | string[]) => parseInt(Array.isArray(value)
? value[0]
: value
)
export default withMiddleware(async (req, res) => {
const { query } = req
const page = parseInt(query.page)
const pageSize = parseInt(query.pageSize)
const page = int(query.page)
const pageSize = int(query.pageSize)
const data = await findArticles(page, pageSize)