Upload signaling server

This commit is contained in:
2025-07-25 16:32:37 +03:00
parent a182befeb6
commit 27fbbe8642
9 changed files with 1049 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
import { z } from "zod/v4";
export const register = z.object({
type: z.literal("register"),
username: z.string(),
password: z.string()
});
export type Register = z.infer<typeof register>;
export const offer = z.object({
type: z.literal("offer"),
id: z.uuid({ version: "v4" }),
offer: z.object({
type: z.literal("offer"),
sdp: z.string()
})
});
export type Offer = z.infer<typeof offer>;
export const answer = z.object({
type: z.literal("answer"),
id: z.uuid({ version: "v4" }),
answer: z.object({
type: z.literal("answer"),
sdp: z.string()
})
});
export type Answer = z.infer<typeof answer>;
export const candidate = z.object({
type: z.literal("candidate"),
id: z.uuid({ version: "v4" }),
candidate: z.looseObject({
candidate: z.string()
})
});
export type Candidate = z.infer<typeof candidate>;
export const schemas = z.union([
register,
offer,
answer,
candidate
]);
export type Message = z.infer<typeof schemas>;