develop-updateui #1

Merged
lethdat merged 78 commits from develop-updateui into master 2026-04-02 05:59:23 +00:00
Showing only changes of commit 8b85736903 - Show all commits

View File

@@ -4,23 +4,17 @@ import { cors } from "hono/cors";
import { languageDetector } from "hono/language";
import isMobile from "is-mobile";
import { JwtProvider } from "../utils/token";
import { RedisClient } from "bun";
type AppFetch = (
input: string | Request | URL,
requestInit?: RequestInit
) => Response | Promise<Response>;
type RedisClientLike = {
connect(): Promise<unknown>;
get(key: string): Promise<string | null>;
set(...args: unknown[]): Promise<unknown> | unknown;
del(key: string): Promise<unknown> | unknown;
};
declare module "hono" {
interface ContextVariableMap {
fetch: AppFetch;
isMobile: boolean;
redis: RedisClientLike;
redis: RedisClient;
jwtProvider: JwtProvider;
jwtPayload: Record<string, unknown>;
userId: string;
@@ -29,7 +23,7 @@ declare module "hono" {
}
}
let redisClientPromise: Promise<RedisClientLike> | null = null;
let redisClientPromise: Promise<RedisClient> | null = null;
const getJwtSecret = () => {
const secret = (process.env.JWT_SECRET || process.env.STREAM_UI_JWT_SECRET || "").trim() || "secret_is_not_configured"
@@ -47,10 +41,13 @@ const getRedisUrl = () => {
return redisUrl;
};
const getRedisClient = async (): Promise<RedisClientLike> => {
const getRedisClient = async (): Promise<RedisClient> => {
console.log("bun", typeof Bun)
if (!redisClientPromise) {
const client = new RedisClient(getRedisUrl())
await client.connect();
return client;
// redisClientPromise = import("Bun").then(async ({ RedisClient }) => {
// const client = new RedisClient(getRedisUrl()) as RedisClientLike;
// await client.connect();