mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Convert event-data, events, session-data, sessions routes.
This commit is contained in:
parent
baa3851fb4
commit
7d5556a637
47 changed files with 692 additions and 136 deletions
|
|
@ -3,42 +3,31 @@ import { checkRequest, getRequestDateRange, getRequestFilters } from 'lib/reques
|
|||
import { badRequest, unauthorized, json } from 'lib/response';
|
||||
import { checkAuth, canViewWebsite } from 'lib/auth';
|
||||
import { getCompareDate } from 'lib/date';
|
||||
import { filterParams } from 'lib/schema';
|
||||
import { getWebsiteStats } from 'queries';
|
||||
|
||||
const schema = z.object({
|
||||
startAt: z.coerce.number(),
|
||||
endAt: z.coerce.number(),
|
||||
// optional
|
||||
url: z.string().optional(),
|
||||
referrer: z.string().optional(),
|
||||
title: z.string().optional(),
|
||||
query: z.string().optional(),
|
||||
event: z.string().optional(),
|
||||
host: z.string().optional(),
|
||||
os: z.string().optional(),
|
||||
browser: z.string().optional(),
|
||||
device: z.string().optional(),
|
||||
country: z.string().optional(),
|
||||
region: z.string().optional(),
|
||||
city: z.string().optional(),
|
||||
tag: z.string().optional(),
|
||||
compare: z.string().optional(),
|
||||
});
|
||||
|
||||
export async function GET(
|
||||
request: Request,
|
||||
{ params }: { params: Promise<{ websiteId: string }> },
|
||||
) {
|
||||
const schema = z.object({
|
||||
startAt: z.coerce.number().int(),
|
||||
endAt: z.coerce.number().int(),
|
||||
compare: z.string().optional(),
|
||||
...filterParams,
|
||||
});
|
||||
|
||||
const { query, error } = await checkRequest(request, schema);
|
||||
|
||||
if (error) {
|
||||
return badRequest(error);
|
||||
}
|
||||
|
||||
const auth = await checkAuth(request);
|
||||
const { websiteId } = await params;
|
||||
const { compare } = query;
|
||||
|
||||
const auth = await checkAuth(request);
|
||||
|
||||
if (!auth || !(await canViewWebsite(auth, websiteId))) {
|
||||
return unauthorized();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue