mirror of
https://github.com/nestriness/nestri.git
synced 2026-08-01 17:34:15 +03:00
chore: Do some minor cleanup
This commit is contained in:
@@ -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),
|
||||
});
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user