mirror of
https://github.com/umami-software/umami.git
synced 2026-02-18 11:35:37 +01:00
Handle website delete. Added response helper functions.
This commit is contained in:
parent
0a411a9ad6
commit
c4b75e4aec
31 changed files with 314 additions and 96 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { getRankings } from 'lib/db';
|
||||
import { useAuth } from 'lib/middleware';
|
||||
import { ok, badRequest } from 'lib/response';
|
||||
|
||||
const sessionColumns = ['browser', 'os', 'device', 'country'];
|
||||
const pageviewColumns = ['url', 'referrer'];
|
||||
|
|
@ -10,12 +11,12 @@ export default async (req, res) => {
|
|||
const { id, type, start_at, end_at } = req.query;
|
||||
|
||||
if (!sessionColumns.includes(type) && !pageviewColumns.includes(type)) {
|
||||
return res.status(400).end();
|
||||
return badRequest(res);
|
||||
}
|
||||
|
||||
const table = sessionColumns.includes(type) ? 'session' : 'pageview';
|
||||
|
||||
const rankings = await getRankings(+id, new Date(+start_at), new Date(+end_at), type, table);
|
||||
|
||||
return res.status(200).json(rankings);
|
||||
return ok(res, rankings);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue