mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-21 08:43:37 +01:00
22 lines
481 B
JavaScript
22 lines
481 B
JavaScript
import { getActiveVisitors } from 'lib/queries';
|
|
import { methodNotAllowed, ok, 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 } = req.query;
|
|
|
|
const websiteId = +id;
|
|
|
|
const result = await getActiveVisitors(websiteId);
|
|
|
|
return ok(res, result);
|
|
}
|
|
|
|
return methodNotAllowed(res);
|
|
};
|