mirror of
https://github.com/umami-software/umami.git
synced 2026-02-15 18:15:35 +01:00
Refactored realtime API. Add dot component and colored dots in log.
This commit is contained in:
parent
f2cfab5078
commit
b72a4c001c
12 changed files with 153 additions and 86 deletions
26
pages/api/realtime/update.js
Normal file
26
pages/api/realtime/update.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { useAuth } from 'lib/middleware';
|
||||
import { ok, methodNotAllowed, badRequest } from 'lib/response';
|
||||
import { getRealtimeData } from 'lib/queries';
|
||||
import { parseToken } from 'lib/crypto';
|
||||
|
||||
export default async (req, res) => {
|
||||
await useAuth(req, res);
|
||||
|
||||
if (req.method === 'GET') {
|
||||
const { start_at } = req.query;
|
||||
|
||||
const token = req.headers['x-umami-token'];
|
||||
|
||||
if (!token) {
|
||||
return badRequest(res);
|
||||
}
|
||||
|
||||
const { websites } = await parseToken(token);
|
||||
|
||||
const data = await getRealtimeData(websites, new Date(+start_at));
|
||||
|
||||
return ok(res, data);
|
||||
}
|
||||
|
||||
return methodNotAllowed(res);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue