mirror of
https://github.com/umami-software/umami.git
synced 2026-02-16 18:45:36 +01:00
Convert teams api routes.
This commit is contained in:
parent
7d5556a637
commit
e51f182403
15 changed files with 354 additions and 4 deletions
30
src/app/api/teams/[teamId]/websites/route.ts
Normal file
30
src/app/api/teams/[teamId]/websites/route.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { z } from 'zod';
|
||||
import { unauthorized, json, badRequest } from 'lib/response';
|
||||
import { canViewTeam, checkAuth } from 'lib/auth';
|
||||
import { checkRequest } from 'lib/request';
|
||||
import { pagingParams } from 'lib/schema';
|
||||
import { getTeamWebsites } from 'queries';
|
||||
|
||||
export async function GET(request: Request, { params }: { params: Promise<{ teamId: string }> }) {
|
||||
const schema = z.object({
|
||||
...pagingParams,
|
||||
});
|
||||
|
||||
const { query, error } = await checkRequest(request, schema);
|
||||
|
||||
if (error) {
|
||||
return badRequest(error);
|
||||
}
|
||||
|
||||
const { teamId } = await params;
|
||||
|
||||
const auth = await checkAuth(request);
|
||||
|
||||
if (!auth || !(await canViewTeam(auth, teamId))) {
|
||||
return unauthorized();
|
||||
}
|
||||
|
||||
const websites = await getTeamWebsites(teamId, query);
|
||||
|
||||
return json(websites);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue