umami/pages/api/website/[id]/active.js

19 lines
424 B
JavaScript
Raw Normal View History

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