From 96a73035f801eddb2ed5606d20b80f17bc8ebbcc Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Sat, 13 May 2023 06:25:28 +0200 Subject: [PATCH] add sessionDestroy func --- example/test.ts | 2 +- mod.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/example/test.ts b/example/test.ts index 42550a0..f2cc3cb 100644 --- a/example/test.ts +++ b/example/test.ts @@ -82,7 +82,7 @@ httpServer.get("/site", (_req, rep) => { httpServer.delete("/session", (req, _rep) => { const username = req.session.user as string ?? ""; if (username.length > 0) { - delete req.session.user; + req.sessionDestroy(); return { code: 200, message: "Logged out!", diff --git a/mod.ts b/mod.ts index dd59a30..544cb13 100644 --- a/mod.ts +++ b/mod.ts @@ -448,6 +448,10 @@ export class RouteRequest { } } + sessionDestroy(): void { + this.session = {}; + } + header(name: string): unknown { const matchingHeader = Array.from(this.headers.keys()).find((headerName) => headerName === name