mirror of
https://github.com/supabase/supabase.git
synced 2026-10-12 21:05:06 +03:00
24 lines
720 B
TypeScript
24 lines
720 B
TypeScript
import { NextApiRequest, NextApiResponse } from 'next'
|
|
import zxcvbn from 'zxcvbn'
|
|
import apiWrapper from 'lib/api/apiWrapper'
|
|
|
|
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
|
|
|
|
async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
const { method } = req
|
|
|
|
switch (method) {
|
|
case 'POST':
|
|
return handlePost(req, res)
|
|
default:
|
|
res.setHeader('Allow', ['POST'])
|
|
res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })
|
|
}
|
|
}
|
|
|
|
const handlePost = async (req: NextApiRequest, res: NextApiResponse) => {
|
|
const { body } = req
|
|
const result = zxcvbn(body.password)
|
|
return res.status(200).json({ result })
|
|
}
|