mirror of
https://github.com/umami-software/umami.git
synced 2026-02-13 00:55:37 +01:00
Renamed id routes for API.
This commit is contained in:
parent
53a991176b
commit
4429198397
42 changed files with 154 additions and 170 deletions
|
|
@ -7,7 +7,7 @@ import { deleteReport, getReport, updateReport } from 'queries';
|
|||
import * as yup from 'yup';
|
||||
|
||||
export interface ReportRequestQuery {
|
||||
id: string;
|
||||
reportId: string;
|
||||
}
|
||||
|
||||
export interface ReportRequestBody {
|
||||
|
|
@ -20,10 +20,10 @@ export interface ReportRequestBody {
|
|||
|
||||
const schema: YupRequest = {
|
||||
GET: yup.object().shape({
|
||||
id: yup.string().uuid().required(),
|
||||
reportId: yup.string().uuid().required(),
|
||||
}),
|
||||
POST: yup.object().shape({
|
||||
id: yup.string().uuid().required(),
|
||||
reportId: yup.string().uuid().required(),
|
||||
websiteId: yup.string().uuid().required(),
|
||||
type: yup
|
||||
.string()
|
||||
|
|
@ -36,7 +36,7 @@ const schema: YupRequest = {
|
|||
.test('len', 'Must not exceed 6000 characters.', val => JSON.stringify(val).length < 6000),
|
||||
}),
|
||||
DELETE: yup.object().shape({
|
||||
id: yup.string().uuid().required(),
|
||||
reportId: yup.string().uuid().required(),
|
||||
}),
|
||||
};
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ export default async (
|
|||
await useAuth(req, res);
|
||||
await useValidate(schema, req, res);
|
||||
|
||||
const { id: reportId } = req.query;
|
||||
const { reportId } = req.query;
|
||||
const {
|
||||
user: { id: userId },
|
||||
} = req.auth;
|
||||
|
|
@ -1,14 +1,12 @@
|
|||
import { uuid } from 'lib/crypto';
|
||||
import { useAuth, useCors, useValidate } from 'lib/middleware';
|
||||
import { NextApiRequestQueryBody, SearchFilter } from 'lib/types';
|
||||
import { NextApiRequestQueryBody } from 'lib/types';
|
||||
import { pageInfo } from 'lib/schema';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { methodNotAllowed, ok } from 'next-basics';
|
||||
import { createReport, getReports } from 'queries';
|
||||
import * as yup from 'yup';
|
||||
|
||||
export interface ReportsRequestQuery extends SearchFilter {}
|
||||
|
||||
export interface ReportRequestBody {
|
||||
websiteId: string;
|
||||
name: string;
|
||||
|
|
@ -60,11 +58,18 @@ export default async (
|
|||
const data = await getReports(
|
||||
{
|
||||
where: {
|
||||
userId: !(websiteId && teamId) ? userId : undefined,
|
||||
websiteId,
|
||||
website: {
|
||||
id: websiteId,
|
||||
userId: !websiteId && !teamId ? userId : undefined,
|
||||
teamId,
|
||||
},
|
||||
},
|
||||
include: {
|
||||
website: true,
|
||||
website: {
|
||||
select: {
|
||||
domain: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
filters,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue