init
This commit is contained in:
commit
28b026a614
17 changed files with 895 additions and 0 deletions
32
common/message/to_client.ts
Normal file
32
common/message/to_client.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { z } from "https://deno.land/x/zod@v3.22.4/mod.ts";
|
||||
import { ParserOutput } from "../utils.ts";
|
||||
|
||||
export type MsgToClient = ParserOutput<typeof message_to_client_parser>;
|
||||
export function message_to_client_parser() {
|
||||
return ping_response_parser()
|
||||
.or(display_parser());
|
||||
}
|
||||
|
||||
export type MsgPingResponse = ParserOutput<typeof ping_response_parser>;
|
||||
export function ping_response_parser() {
|
||||
return z.object({
|
||||
kind: z.literal("ping_response"),
|
||||
content: z.object({
|
||||
message: z.string(),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
export type MsgDisplay = ParserOutput<typeof display_parser>;
|
||||
export function display_parser() {
|
||||
return z.object({
|
||||
kind: z.literal("display"),
|
||||
content: z.object({
|
||||
raw: z.string(),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
function char_parser() {
|
||||
return z.string().length(1);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue