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:
2026-07-17 22:47:50 -05:00
parent 03c7e0fd30
commit 9c56d278e6
10 changed files with 83 additions and 95 deletions
-39
View File
@@ -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",
});
-39
View File
@@ -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!,
});
+7 -2
View File
@@ -1,7 +1,12 @@
import { auth } from "../lib/auth";
import { Elysia, t } from "elysia";
const app = new Elysia().mount("/auth", auth.handler).listen(3000);
const app = new Elysia()
.mount("/auth", auth.handler)
.get("/health", () => "OK", {
response: t.String(),
})
.listen(3000);
export type App = typeof app;
@@ -11,5 +16,5 @@ export const PUT = app.put;
export const DELETE = app.delete;
console.log(
`🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`,
`🦊 Elysia is running at http://${app.server?.hostname}:${app.server?.port}`,
);
+10
View File
@@ -0,0 +1,10 @@
import Elysia from "elysia";
export const realtime = new Elysia().ws("/realtime", {
open: (ws) => {
console.log("WebSocket connection opened");
},
message: (ws, message) => {
console.log("Received message:", message);
},
});
+22
View File
@@ -0,0 +1,22 @@
export type Message = {
id: number;
roomId: string;
username: string;
content: string;
timestamp: number;
deleted: boolean;
};
// Client -> Server
export type ClientMessage =
| { type: "join"; roomId: string }
| { type: "leave"; roomId: string }
| { type: "message"; roomId: string; m: Message }
| { type: "sync"; roomId: string };
// Server -> Client(s)
export type ServerMessage =
| { type: "joined"; username: string }
| { type: "left"; username: string }
| { type: "message"; username: string; m: Message }
| { type: "sync"; roomId: string; messages: Message[] };