Add web client and containerized deployment stack
All checks were successful
CI / test (push) Successful in 19s
All checks were successful
CI / test (push) Successful in 19s
Web client: - Added React + TypeScript + Vite + Tailwind application in web/. - Implemented auth, chat list, chat messages, typing indicators, file uploads, and voice recording/playback. - Added typed API layer, Zustand stores, and realtime websocket hook integration. Containerization: - Added backend Dockerfile and project .dockerignore. - Added web multi-stage Dockerfile with nginx static hosting and API/WS reverse proxy. - Added full docker-compose stack with postgres, redis, minio, backend, worker, mailpit, and web. - Added MinIO bucket bootstrap init job and updated README with Docker quick-start.
This commit is contained in:
57
web/src/api/chats.ts
Normal file
57
web/src/api/chats.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { http } from "./http";
|
||||
import type { Chat, Message, MessageType } from "../chat/types";
|
||||
|
||||
export async function getChats(): Promise<Chat[]> {
|
||||
const { data } = await http.get<Chat[]>("/chats");
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function createPrivateChat(memberId: number): Promise<Chat> {
|
||||
const { data } = await http.post<Chat>("/chats", {
|
||||
type: "private",
|
||||
title: null,
|
||||
member_ids: [memberId]
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function getMessages(chatId: number, beforeId?: number): Promise<Message[]> {
|
||||
const { data } = await http.get<Message[]>(`/messages/${chatId}`, {
|
||||
params: {
|
||||
limit: 50,
|
||||
before_id: beforeId
|
||||
}
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function sendMessage(chatId: number, text: string, type: MessageType = "text"): Promise<Message> {
|
||||
const { data } = await http.post<Message>("/messages", { chat_id: chatId, text, type });
|
||||
return data;
|
||||
}
|
||||
|
||||
export interface UploadUrlResponse {
|
||||
upload_url: string;
|
||||
file_url: string;
|
||||
object_key: string;
|
||||
expires_in: number;
|
||||
required_headers: Record<string, string>;
|
||||
}
|
||||
|
||||
export async function requestUploadUrl(file: File): Promise<UploadUrlResponse> {
|
||||
const { data } = await http.post<UploadUrlResponse>("/media/upload-url", {
|
||||
file_name: file.name,
|
||||
file_type: file.type || "application/octet-stream",
|
||||
file_size: file.size
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function attachFile(messageId: number, fileUrl: string, fileType: string, fileSize: number): Promise<void> {
|
||||
await http.post("/media/attachments", {
|
||||
message_id: messageId,
|
||||
file_url: fileUrl,
|
||||
file_type: fileType,
|
||||
file_size: fileSize
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user