mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 22:57:12 +01:00
fix response error return type
This commit is contained in:
parent
460200dfef
commit
8083482ba8
12 changed files with 23 additions and 25 deletions
|
|
@ -20,7 +20,7 @@ export async function GET(request: Request, { params }: { params: Promise<{ team
|
|||
const team = await getTeam(teamId, { includeMembers: true });
|
||||
|
||||
if (!team) {
|
||||
return notFound('Team not found.');
|
||||
return notFound({ message: 'Team not found.' });
|
||||
}
|
||||
|
||||
return json(team);
|
||||
|
|
@ -41,7 +41,7 @@ export async function POST(request: Request, { params }: { params: Promise<{ tea
|
|||
const { teamId } = await params;
|
||||
|
||||
if (!(await canUpdateTeam(auth, teamId))) {
|
||||
return unauthorized('You must be the owner of this team.');
|
||||
return unauthorized({ message: 'You must be the owner of this team.' });
|
||||
}
|
||||
|
||||
const team = await updateTeam(teamId, body);
|
||||
|
|
@ -62,7 +62,7 @@ export async function DELETE(
|
|||
const { teamId } = await params;
|
||||
|
||||
if (!(await canDeleteTeam(auth, teamId))) {
|
||||
return unauthorized('You must be the owner of this team.');
|
||||
return unauthorized({ message: 'You must be the owner of this team.' });
|
||||
}
|
||||
|
||||
await deleteTeam(teamId);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export async function GET(
|
|||
const { teamId, userId } = await params;
|
||||
|
||||
if (!(await canUpdateTeam(auth, teamId))) {
|
||||
return unauthorized('You must be the owner of this team.');
|
||||
return unauthorized({ message: 'You must be the owner of this team.' });
|
||||
}
|
||||
|
||||
const teamUser = await getTeamUser(teamId, userId);
|
||||
|
|
@ -42,13 +42,13 @@ export async function POST(
|
|||
const { teamId, userId } = await params;
|
||||
|
||||
if (!(await canUpdateTeam(auth, teamId))) {
|
||||
return unauthorized('You must be the owner of this team.');
|
||||
return unauthorized({ message: 'You must be the owner of this team.' });
|
||||
}
|
||||
|
||||
const teamUser = await getTeamUser(teamId, userId);
|
||||
|
||||
if (!teamUser) {
|
||||
return badRequest('The User does not exists on this team.');
|
||||
return badRequest({ message: 'The User does not exists on this team.' });
|
||||
}
|
||||
|
||||
const user = await updateTeamUser(teamUser.id, body);
|
||||
|
|
@ -69,13 +69,13 @@ export async function DELETE(
|
|||
const { teamId, userId } = await params;
|
||||
|
||||
if (!(await canDeleteTeamUser(auth, teamId, userId))) {
|
||||
return unauthorized('You must be the owner of this team.');
|
||||
return unauthorized({ message: 'You must be the owner of this team.' });
|
||||
}
|
||||
|
||||
const teamUser = await getTeamUser(teamId, userId);
|
||||
|
||||
if (!teamUser) {
|
||||
return badRequest('The User does not exists on this team.');
|
||||
return badRequest({ message: 'The User does not exists on this team.' });
|
||||
}
|
||||
|
||||
await deleteTeamUser(teamId, userId);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ export async function GET(request: Request, { params }: { params: Promise<{ team
|
|||
const { teamId } = await params;
|
||||
|
||||
if (!(await canViewTeam(auth, teamId))) {
|
||||
return unauthorized('You must be the owner of this team.');
|
||||
return unauthorized({ message: 'You must be the owner of this team.' });
|
||||
}
|
||||
|
||||
const filters = await getQueryFilters(query);
|
||||
|
|
@ -71,7 +71,7 @@ export async function POST(request: Request, { params }: { params: Promise<{ tea
|
|||
const teamUser = await getTeamUser(teamId, userId);
|
||||
|
||||
if (teamUser) {
|
||||
return badRequest('User is already a member of the Team.');
|
||||
return badRequest({ message: 'User is already a member of the Team.' });
|
||||
}
|
||||
|
||||
const users = await createTeamUser(userId, teamId, role);
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@ export async function POST(request: Request) {
|
|||
});
|
||||
|
||||
if (!team) {
|
||||
return notFound('Team not found.');
|
||||
return notFound({ message: 'Team not found.' });
|
||||
}
|
||||
|
||||
const teamUser = await getTeamUser(team.id, auth.user.id);
|
||||
|
||||
if (teamUser) {
|
||||
return badRequest('User is already a team member.');
|
||||
return badRequest({ message: 'User is already a team member.' });
|
||||
}
|
||||
|
||||
const user = await createTeamUser(auth.user.id, team.id, ROLES.teamMember);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue