mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 21:57:16 +01:00
35 lines
811 B
TypeScript
35 lines
811 B
TypeScript
import { useCors, useValidate } from 'lib/middleware';
|
|
import { NextApiRequestQueryBody, SearchFilter } from 'lib/types';
|
|
import { pageInfo } from 'lib/schema';
|
|
import { NextApiResponse } from 'next';
|
|
import { methodNotAllowed } from 'next-basics';
|
|
import userTeams from 'pages/api/users/[id]/teams';
|
|
import * as yup from 'yup';
|
|
|
|
export interface MyTeamsRequestQuery extends SearchFilter {
|
|
id: string;
|
|
}
|
|
|
|
const schema = {
|
|
GET: yup.object().shape({
|
|
...pageInfo,
|
|
}),
|
|
};
|
|
|
|
export default async (
|
|
req: NextApiRequestQueryBody<MyTeamsRequestQuery, any>,
|
|
res: NextApiResponse,
|
|
) => {
|
|
await useCors(req, res);
|
|
|
|
req.yup = schema;
|
|
await useValidate(req, res);
|
|
|
|
if (req.method === 'GET') {
|
|
req.query.id = req.auth.user.id;
|
|
|
|
return userTeams(req, res);
|
|
}
|
|
|
|
return methodNotAllowed(res);
|
|
};
|