chore: Do some minor cleanup

This commit is contained in:
Wanjohi
2025-10-25 22:27:35 +03:00
parent 01eb63b36f
commit 687bc47870
2 changed files with 7 additions and 7 deletions

View File

@@ -2,11 +2,10 @@ import { z } from "zod/v4";
import { RedisClient } from "bun";
import { subjects } from "../subjects.js";
import { issuer } from "@openauthjs/openauth";
import { RedisStorage } from "./src/storage.js";
import { Team } from "@nestri/core/team/index";
import { RedisStorage } from "./src/storage.js";
import { CodeProvider } from "@openauthjs/openauth/provider/code";
//!TODO: Add an auth storage adapter, maybe redis or postgres
const storage = RedisStorage({
client: new RedisClient(process.env.REDIS_URL),
});

View File

@@ -32,13 +32,14 @@ export interface RedisStorageOptions {
defaultTTL?: number;
client: typeof RedisClient;
}
/**
* Creates a Cloudflare KV store.
* Creates a Redis DB store.
* @param options - The config for the adapter.
*/
export function RedisStorage(options: RedisStorageOptions): StorageAdapter {
const { client } = options;
const prefix = "storage";
const prefix = "auth";
function createKey(key: string[]): string {
return `${prefix}:${joinKey(key)}`;
@@ -48,6 +49,7 @@ export function RedisStorage(options: RedisStorageOptions): StorageAdapter {
const withoutPrefix = redisKey.slice(prefix.length + 1);
return withoutPrefix.split(separator);
}
return {
async get(key: string[]) {
const redisKey = createKey(key);
@@ -80,9 +82,8 @@ export function RedisStorage(options: RedisStorageOptions): StorageAdapter {
},
async *scan(prefix: string[]) {
const scanPattern = `${createKey(prefix)}${
prefix.length ? separator : ""
}*`;
const scanPattern = `${createKey(prefix)}${prefix.length ? separator : ""}*`;
let cursor = "0";
do {