Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"exports": "./mod.ts",
"lock": false,
"tasks": {
"check": "deno cache --allow-import src/mod.ts",
"check": "deno cache --allow-import mod.ts",
"test": "deno test --allow-import test",
"ok": "deno fmt && deno lint && deno task test && deno task check",
"clean": "git clean -fX out test/cov_profile test/coverage coverage.lcov",
Expand All @@ -22,9 +22,9 @@
"proseWrap": "preserve"
},
"imports": {
"@grammyjs/debug": "jsr:@grammyjs/debug@^0.1.2",
"@std/assert": "jsr:@std/assert@^1.0.11",
"@std/testing": "jsr:@std/testing@^1.0.9",
"@grammyjs/debug": "jsr:@grammyjs/debug@0.1.2",
"@std/assert": "jsr:@std/assert@^1.0.17",
"@std/testing": "jsr:@std/testing@^1.0.17",
// TODO: replace this with jsr when grammY is published there
"grammy": "https://raw.githubusercontent.com/grammyjs/grammY/refs/heads/v2/src/mod.ts"
}
Expand Down
7 changes: 5 additions & 2 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ export class MemorySessionStorage<S> implements StorageAdapter<S> {
this.delete(key);
return undefined;
}
return value.session;
return structuredClone(value.session);
}

readAllKeys(): string[] {
Expand All @@ -707,7 +707,10 @@ export class MemorySessionStorage<S> implements StorageAdapter<S> {
}

write(key: string, value: S) {
this.storage.set(key, addExpiryDate(value, this.timeToLive));
this.storage.set(
key,
addExpiryDate(structuredClone(value), this.timeToLive),
);
}

delete(key: string) {
Expand Down
11 changes: 3 additions & 8 deletions test/mod.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { Composer, type Context, type MiddlewareFn } from "grammy";
import {
assert,
assertEquals,
assertRejects,
assertThrows,
} from "jsr:@std/assert";
import { describe, it } from "jsr:@std/testing/bdd";
import { spy } from "jsr:@std/testing/mock";
import { assert, assertEquals, assertRejects, assertThrows } from "@std/assert";
import { describe, it } from "@std/testing/bdd";
import { spy } from "@std/testing/mock";
import {
type Enhance,
enhanceStorage,
Expand Down