1
0
mirror of https://github.com/kremalicious/umami.git synced 2024-12-26 14:57:39 +01:00
umami/pages/api/website/[id]/active.js

22 lines
481 B
JavaScript
Raw Normal View History

2020-08-18 09:51:32 +02:00
import { getActiveVisitors } from 'lib/queries';
import { methodNotAllowed, ok, unauthorized } from 'lib/response';
import { allowQuery } from 'lib/auth';
2020-08-18 09:51:32 +02:00
export default async (req, res) => {
2020-09-11 22:49:43 +02:00
if (req.method === 'GET') {
if (!(await allowQuery(req))) {
return unauthorized(res);
}
2020-09-11 22:49:43 +02:00
const { id } = req.query;
2020-08-18 09:51:32 +02:00
const websiteId = +id;
const result = await getActiveVisitors(websiteId);
2020-09-11 22:49:43 +02:00
return ok(res, result);
}
return methodNotAllowed(res);
2020-08-18 09:51:32 +02:00
};