mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 07:37:11 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
6ef1f2e9f9
22 changed files with 411 additions and 93 deletions
|
|
@ -4,7 +4,7 @@ import { useAuth, useCors } from 'lib/middleware';
|
|||
import { NextApiRequestQueryBody, ReportSearchFilterType, SearchFilter } from 'lib/types';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { createReport, getReportsByWebsiteId } from 'queries';
|
||||
import { createReport, getReportsByUserId, getReportsByWebsiteId } from 'queries';
|
||||
|
||||
export interface ReportsRequestQuery extends SearchFilter<ReportSearchFilterType> {}
|
||||
|
||||
|
|
@ -26,20 +26,14 @@ export default async (
|
|||
await useCors(req, res);
|
||||
await useAuth(req, res);
|
||||
|
||||
const { websiteId } = req.query;
|
||||
|
||||
const {
|
||||
user: { id: userId },
|
||||
} = req.auth;
|
||||
|
||||
if (req.method === 'GET') {
|
||||
if (!(websiteId && (await canViewWebsite(req.auth, websiteId)))) {
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const { page, filter, pageSize } = req.query;
|
||||
|
||||
const data = await getReportsByWebsiteId(websiteId, {
|
||||
const data = await getReportsByUserId(userId, {
|
||||
page,
|
||||
filter,
|
||||
pageSize: +pageSize || null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue