mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 15:23:38 +01:00
feature(api): add event types endpoint
This commit is contained in:
parent
8b6308d686
commit
67551fb129
25
pages/api/website/[id]/event-types.js
Normal file
25
pages/api/website/[id]/event-types.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { getEventTypes } from 'lib/queries';
|
||||||
|
import { ok, methodNotAllowed, unauthorized } from 'lib/response';
|
||||||
|
import { allowQuery } from 'lib/auth';
|
||||||
|
|
||||||
|
export default async (req, res) => {
|
||||||
|
if (req.method === 'GET') {
|
||||||
|
if (!(await allowQuery(req))) {
|
||||||
|
return unauthorized(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { id, start_at, end_at, url } = req.query;
|
||||||
|
|
||||||
|
const websiteId = +id;
|
||||||
|
const startDate = new Date(+start_at);
|
||||||
|
const endDate = new Date(+end_at);
|
||||||
|
|
||||||
|
const eventTypes = await getEventTypes(websiteId, startDate, endDate, undefined, undefined, {
|
||||||
|
url,
|
||||||
|
});
|
||||||
|
|
||||||
|
return ok(res, eventTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
return methodNotAllowed(res);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user