Renamed id routes for API.

This commit is contained in:
Mike Cao 2024-01-31 22:08:48 -08:00
parent 53a991176b
commit 4429198397
42 changed files with 154 additions and 170 deletions

View file

@ -8,7 +8,7 @@ import { deleteTeam, getTeam, updateTeam } from 'queries';
import * as yup from 'yup';
export interface TeamRequestQuery {
id: string;
teamId: string;
}
export interface TeamRequestBody {
@ -18,7 +18,7 @@ export interface TeamRequestBody {
const schema = {
GET: yup.object().shape({
id: yup.string().uuid().required(),
teamId: yup.string().uuid().required(),
}),
POST: yup.object().shape({
id: yup.string().uuid().required(),
@ -26,7 +26,7 @@ const schema = {
accessCode: yup.string().max(50),
}),
DELETE: yup.object().shape({
id: yup.string().uuid().required(),
teamId: yup.string().uuid().required(),
}),
};
@ -37,7 +37,7 @@ export default async (
await useAuth(req, res);
await useValidate(schema, req, res);
const { id: teamId } = req.query;
const { teamId } = req.query;
if (req.method === 'GET') {
if (!(await canViewTeam(req.auth, teamId))) {

View file

@ -7,7 +7,7 @@ import { deleteTeamUser, getTeamUser, updateTeamUser } from 'queries';
import * as yup from 'yup';
export interface TeamUserRequestQuery {
id: string;
teamId: string;
userId: string;
}
@ -17,7 +17,7 @@ export interface TeamUserRequestBody {
const schema = {
DELETE: yup.object().shape({
id: yup.string().uuid().required(),
teamId: yup.string().uuid().required(),
userId: yup.string().uuid().required(),
}),
POST: yup.object().shape({
@ -35,7 +35,7 @@ export default async (
await useAuth(req, res);
await useValidate(schema, req, res);
const { id: teamId, userId } = req.query;
const { teamId, userId } = req.query;
if (req.method === 'POST') {
if (!(await canUpdateTeam(req.auth, teamId))) {

View file

@ -8,7 +8,7 @@ import { createTeamUser, getTeamUser, getTeamUsers } from 'queries';
import * as yup from 'yup';
export interface TeamUserRequestQuery extends SearchFilter {
id: string;
teamId: string;
}
export interface TeamUserRequestBody {
@ -18,7 +18,7 @@ export interface TeamUserRequestBody {
const schema = {
GET: yup.object().shape({
id: yup.string().uuid().required(),
teamId: yup.string().uuid().required(),
...pageInfo,
}),
POST: yup.object().shape({
@ -37,7 +37,7 @@ export default async (
await useAuth(req, res);
await useValidate(schema, req, res);
const { id: teamId } = req.query;
const { teamId } = req.query;
if (req.method === 'GET') {
if (!(await canViewTeam(req.auth, teamId))) {

View file

@ -9,7 +9,7 @@ import { createWebsite, getTeamWebsites } from 'queries';
import { uuid } from 'lib/crypto';
export interface TeamWebsiteRequestQuery extends SearchFilter {
id: string;
teamId: string;
}
export interface TeamWebsiteRequestBody {
@ -20,7 +20,7 @@ export interface TeamWebsiteRequestBody {
const schema = {
GET: yup.object().shape({
id: yup.string().uuid().required(),
teamId: yup.string().uuid().required(),
...pageInfo,
}),
POST: yup.object().shape({
@ -37,7 +37,7 @@ export default async (
await useAuth(req, res);
await useValidate(schema, req, res);
const { id: teamId } = req.query;
const { teamId } = req.query;
if (req.method === 'GET') {
if (!(await canViewTeam(req.auth, teamId))) {

View file

@ -6,6 +6,7 @@ import { NextApiResponse } from 'next';
import { methodNotAllowed, notFound, ok } from 'next-basics';
import { createTeamUser, findTeam, getTeamUser } from 'queries';
import * as yup from 'yup';
export interface TeamsJoinRequestBody {
accessCode: string;
}