From afe40947dddd136649b291212d6ce873c0013c25 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Tue, 21 Jan 2025 13:13:29 +0100 Subject: [PATCH] msw: Implement `getSession()` helper fn --- packages/crates-io-msw/utils/session.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 packages/crates-io-msw/utils/session.js diff --git a/packages/crates-io-msw/utils/session.js b/packages/crates-io-msw/utils/session.js new file mode 100644 index 0000000000..31e0d27f77 --- /dev/null +++ b/packages/crates-io-msw/utils/session.js @@ -0,0 +1,12 @@ +import { db } from '../index.js'; + +export function getSession() { + let session = db.mswSession.findFirst({}); + if (!session) { + return {}; + } + + let user = session.user; + + return { session, user }; +}