generated from pure_sagacity/turborepo-starter-project
added realtime, bruno stuff, and removed s3/redis
removed zod because elysia has it built in changed compose.yml to docker-compose.yml because my icon shows it as docker-compose that way
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
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",
|
||||
});
|
||||
@@ -1,39 +0,0 @@
|
||||
import { S3Client } from "bun";
|
||||
|
||||
interface S3Options {
|
||||
accessKeyId: string
|
||||
secretAccessKey: string
|
||||
bucket: string
|
||||
endpoint: string
|
||||
}
|
||||
|
||||
class S3 {
|
||||
private client: S3Client;
|
||||
|
||||
constructor(options: S3Options) {
|
||||
this.client = new S3Client(options);
|
||||
}
|
||||
|
||||
async upload(key: string, body: File) {
|
||||
return await this.client.write(key, body);
|
||||
}
|
||||
|
||||
async get(key: string) {
|
||||
return await this.client.file(key);
|
||||
}
|
||||
|
||||
async delete(key: string) {
|
||||
return await this.client.delete(key);
|
||||
}
|
||||
|
||||
async presignedUrl(key: string, expiresIn: number = 3600) {
|
||||
return await this.client.presign(key, { expiresIn });
|
||||
}
|
||||
}
|
||||
|
||||
export const s3 = new S3({
|
||||
accessKeyId: process.env.S3_ACCESS_KEY_ID!,
|
||||
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY!,
|
||||
bucket: process.env.S3_BUCKET!,
|
||||
endpoint: process.env.S3_ENDPOINT!,
|
||||
});
|
||||
Reference in New Issue
Block a user