mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-16 02:05:04 +01:00
d784b2a8db
# Conflicts: # pages/api/account/index.js
25 lines
548 B
JavaScript
25 lines
548 B
JavaScript
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
|
import { allowQuery } from 'lib/auth';
|
|
import { useCors } from 'lib/middleware';
|
|
import { getActiveVisitors } from 'queries';
|
|
|
|
export default async (req, res) => {
|
|
if (req.method === 'GET') {
|
|
await useCors(req, res);
|
|
|
|
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);
|
|
};
|