mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Refactor database queries.
This commit is contained in:
parent
a248f35db2
commit
f4ca353b5c
24 changed files with 371 additions and 329 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { getWebsite, getSession, createSession } from 'lib/db';
|
||||
import { getWebsiteByUuid, getSessionByUuid, createSession } from 'lib/queries';
|
||||
import { getClientInfo } from 'lib/request';
|
||||
import { uuid, isValidId, parseToken } from 'lib/crypto';
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ export async function verifySession(req) {
|
|||
if (!token || token.website_uuid !== website_uuid) {
|
||||
const { userAgent, browser, os, ip, country, device } = await getClientInfo(req, payload);
|
||||
|
||||
const website = await getWebsite({ website_uuid });
|
||||
const website = await getWebsiteByUuid(website_uuid);
|
||||
|
||||
if (!website) {
|
||||
throw new Error(`Website not found: ${website_uuid}`);
|
||||
|
|
@ -28,7 +28,7 @@ export async function verifySession(req) {
|
|||
const { website_id } = website;
|
||||
const session_uuid = uuid(website_id, hostname, ip, userAgent, os);
|
||||
|
||||
let session = await getSession({ session_uuid });
|
||||
let session = await getSessionByUuid(session_uuid);
|
||||
|
||||
if (!session) {
|
||||
session = await createSession(website_id, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue