From 7ad3bff073e6e721845b943e2eb959ed1305ddbb Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Sun, 22 Aug 2021 12:58:25 +0400 Subject: [PATCH] add wordlistdb cleanup on user delete --- account/src/routers/api-router.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/account/src/routers/api-router.ts b/account/src/routers/api-router.ts index b3257b2..33dad97 100644 --- a/account/src/routers/api-router.ts +++ b/account/src/routers/api-router.ts @@ -4,6 +4,7 @@ import { getLingdocsUser, updateLingdocsUser, createWordlistDatabase, + deleteWordlistDatabase, } from "../lib/couch-db"; import { getHash, @@ -14,7 +15,6 @@ import { sendVerificationEmail, } from "../lib/mail-utils"; import * as T from "../../../website/src/lib/account-types"; -import * as FT from "../../../website/src/lib/functions-types"; import env from "../lib/env-vars"; function sendResponse(res: Response, payload: T.APIResponse) { @@ -135,7 +135,9 @@ apiRouter.put("/user/upgrade", async (req, res, next) => { apiRouter.delete("/user", async (req, res, next) => { try { if (!req.user) throw new Error("user not found"); - await deleteLingdocsUser(req.user.userId); + const dUser = deleteLingdocsUser(req.user.userId); + const dDb = deleteWordlistDatabase(req.user.userId); + await Promise.all([dUser, dDb]); sendResponse(res, { ok: true, message: "user delted" }); } catch (e) { next(e);