finished setting up server + added docker compose

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-04-26 23:06:06 -05:00
parent a6848fb7e9
commit 610c9606dc
13 changed files with 684 additions and 30 deletions
+39
View File
@@ -0,0 +1,39 @@
import { RedisClient } from "bun";
type RedisOptions = {
url: string;
options?: Bun.RedisOptions;
};
class Redis {
private client: RedisClient;
constructor(options: RedisOptions) {
this.client = new RedisClient(options.url, options.options);
}
async set(key: string, value: string, expireInSeconds?: number) {
if (expireInSeconds) {
await this.client.set(key, value, "EX", expireInSeconds);
} else {
await this.client.set(key, value);
}
}
async get<T>(key: string): Promise<T | null> {
const value = await this.client.get(key);
return value ? (JSON.parse(value) as T) : null;
}
async del(key: string) {
await this.client.del(key);
}
async exists(key: string): Promise<boolean> {
return await this.client.exists(key);
}
}
export const redis = new Redis({
url: process.env.REDIS_URL || "redis://localhost:6379",
});