-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from beabee-communityrm/feat/persistent-session
Feat(persistent-session): Implementation
- Loading branch information
Showing
31 changed files
with
350 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { StorageAdapter } from "../deps/index.ts"; | ||
|
||
/** | ||
* Key-value storage adapter for Deno. | ||
* Based on https://github.com/grammyjs/storages/blob/main/packages/denokv/src/adapter.ts | ||
* @see https://docs.deno.com/examples/kv/ | ||
* @see https://github.com/grammyjs/storages/tree/main/packages/denokv | ||
*/ | ||
export class KeyValueStorageAdapter<T> implements StorageAdapter<T> { | ||
constructor( | ||
private kv: Deno.Kv, | ||
private prefix: Deno.KvKeyPart[] = ["sessions"], | ||
) {} | ||
|
||
async read(key: string): Promise<T | undefined> { | ||
const result = await this.kv.get([...this.prefix, key]); | ||
return result.value !== null ? result.value as T : undefined; | ||
} | ||
|
||
async write(key: string, value: T) { | ||
await this.kv.set([...this.prefix, key], value); | ||
} | ||
|
||
async delete(key: string) { | ||
await this.kv.delete([...this.prefix, key]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export enum AbortControllerState { | ||
ACTIVE = "active", | ||
ABORTED = "aborted", | ||
NULL = "null", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.