diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/database.ts | 5 | ||||
-rw-r--r-- | src/index.ts | 14 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/database.ts b/src/database.ts index 67de483..26fa76f 100644 --- a/src/database.ts +++ b/src/database.ts @@ -803,6 +803,11 @@ export async function fetchSession(sessionId: string): Promise<WithId<SessionSch return await sessionsCollection?.findOne({ _id: sessionId as any } ) } + +export async function deleteSession(sessionId: string) { + return await sessionsCollection?.deleteOne({ _id: sessionId as any } ) +} + export async function fetchAccount(minecraftUuid: string): Promise<WithId<AccountSchema> | null> { return await accountsCollection?.findOne({ minecraftUuid }) } diff --git a/src/index.ts b/src/index.ts index 6ac23cd..fd2b724 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import { createSession, fetchAccountFromDiscord, fetchAllLeaderboardsCategorized, fetchLeaderboard, fetchMemberLeaderboardSpots, fetchSession, finishedCachingRawLeaderboards, leaderboardUpdateMemberQueue, leaderboardUpdateProfileQueue, updateAccount, fetchServerStatus } from './database.js' +import { createSession, fetchAccountFromDiscord, fetchAllLeaderboardsCategorized, fetchLeaderboard, fetchMemberLeaderboardSpots, fetchSession, finishedCachingRawLeaderboards, leaderboardUpdateMemberQueue, leaderboardUpdateProfileQueue, updateAccount, fetchServerStatus, deleteSession } from './database.js' import { fetchElection, fetchMemberProfile, fetchUser } from './hypixel.js' import rateLimit from 'express-rate-limit' import * as constants from './constants.js' @@ -186,6 +186,18 @@ app.post('/accounts/session', async (req, res) => { } }) +app.delete('/accounts/session', async (req, res) => { + // delete a session + try { + const { uuid } = req.body + const session = await deleteSession(uuid) + res.json({ ok: true }) + } catch (err) { + console.error(err) + res.json({ ok: false }) + } +}) + app.post('/accounts/update', async (req, res) => { // it checks against the key, so it's kind of secure |