2
0

refactor(models): 🎨 Build types from validation schemas

This commit is contained in:
Baptiste Arnaud
2022-06-07 08:49:12 +02:00
parent c67fa7d9c1
commit e79ff09b0f
62 changed files with 1268 additions and 734 deletions

View File

@@ -20,6 +20,10 @@
"models": "*",
"next": "^12.1.6"
},
"peerDependencies": {
"next": "^12.1.6",
"models": "*"
},
"scripts": {
"build": "yarn rollup -c",
"dx": "yarn rollup -c --watch"

View File

@@ -25,7 +25,7 @@ export default [
],
plugins: [
peerDepsExternal(),
resolve({ preferBuiltins: true }),
resolve(),
commonjs(),
typescript({ tsconfig: './tsconfig.json' }),
],

View File

@@ -1,19 +1,23 @@
import { NextApiRequest, NextApiResponse } from 'next'
export const methodNotAllowed = (res: NextApiResponse) =>
res.status(405).json({ message: 'Method Not Allowed' })
export const methodNotAllowed = (
res: NextApiResponse,
customMessage?: string
) => res.status(405).json({ message: customMessage ?? 'Method Not Allowed' })
export const notAuthenticated = (res: NextApiResponse) =>
res.status(401).json({ message: 'Not authenticated' })
export const notAuthenticated = (
res: NextApiResponse,
customMessage?: string
) => res.status(401).json({ message: customMessage ?? 'Not authenticated' })
export const notFound = (res: NextApiResponse) =>
res.status(404).json({ message: 'Not found' })
export const notFound = (res: NextApiResponse, customMessage?: string) =>
res.status(404).json({ message: customMessage ?? 'Not found' })
export const badRequest = (res: NextApiResponse) =>
res.status(400).json({ message: 'Bad Request' })
export const badRequest = (res: NextApiResponse, customMessage?: any) =>
res.status(400).json({ message: customMessage ?? 'Bad Request' })
export const forbidden = (res: NextApiResponse) =>
res.status(403).json({ message: 'Bad Request' })
export const forbidden = (res: NextApiResponse, customMessage?: string) =>
res.status(403).json({ message: customMessage ?? 'Bad Request' })
export const initMiddleware =
(