mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 23:27:12 +01:00
More yup validations.
This commit is contained in:
parent
2ccb8d0a3c
commit
ce2a83a09f
12 changed files with 99 additions and 50 deletions
|
|
@ -5,6 +5,7 @@ import { NextApiResponse } from 'next';
|
|||
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { deleteTeamUser } from 'queries';
|
||||
import * as yup from 'yup';
|
||||
|
||||
export interface TeamUserRequestQuery {
|
||||
id: string;
|
||||
userId: string;
|
||||
|
|
|
|||
|
|
@ -1,24 +1,27 @@
|
|||
import { canViewTeam } from 'lib/auth';
|
||||
import { useAuth } from 'lib/middleware';
|
||||
import { useAuth, useValidate } from 'lib/middleware';
|
||||
import { NextApiRequestQueryBody, SearchFilter, TeamSearchFilterType } from 'lib/types';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { getUsersByTeamId } from 'queries';
|
||||
|
||||
import * as yup from 'yup';
|
||||
export interface TeamUserRequestQuery extends SearchFilter<TeamSearchFilterType> {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface TeamUserRequestBody {
|
||||
email: string;
|
||||
roleId: string;
|
||||
}
|
||||
const schema = {
|
||||
GET: yup.object().shape({
|
||||
id: yup.string().uuid().required(),
|
||||
}),
|
||||
};
|
||||
|
||||
export default async (
|
||||
req: NextApiRequestQueryBody<TeamUserRequestQuery, TeamUserRequestBody>,
|
||||
req: NextApiRequestQueryBody<TeamUserRequestQuery, any>,
|
||||
res: NextApiResponse,
|
||||
) => {
|
||||
await useAuth(req, res);
|
||||
req.yup = schema;
|
||||
await useValidate(req, res);
|
||||
|
||||
const { id: teamId } = req.query;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue