Phase8
This commit is contained in:
38
packages/contracts/src/join.ts
Normal file
38
packages/contracts/src/join.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { gameServerStatusSchema, serverEditionSchema } from './servers';
|
||||
|
||||
export const edgeBackendSchema = z.object({
|
||||
host: z.string(),
|
||||
port: z.number().int(),
|
||||
});
|
||||
|
||||
export const edgeActionSchema = z.enum(['proxy', 'start', 'wait', 'reject']);
|
||||
|
||||
export const edgeResolveResponseSchema = z.object({
|
||||
serverId: z.string().uuid(),
|
||||
slug: z.string(),
|
||||
status: gameServerStatusSchema,
|
||||
joinToStartEnabled: z.boolean(),
|
||||
edition: serverEditionSchema,
|
||||
backend: edgeBackendSchema.nullable(),
|
||||
action: edgeActionSchema,
|
||||
message: z.string().optional(),
|
||||
});
|
||||
|
||||
export const edgeStartRequestSchema = z.object({
|
||||
clientIp: z.string().min(1).max(64),
|
||||
});
|
||||
|
||||
export const edgeStartResponseSchema = z.object({
|
||||
resolve: edgeResolveResponseSchema,
|
||||
started: z.boolean(),
|
||||
jobId: z.string().optional(),
|
||||
queuePosition: z.number().int().optional(),
|
||||
});
|
||||
|
||||
export type EdgeBackend = z.infer<typeof edgeBackendSchema>;
|
||||
export type EdgeAction = z.infer<typeof edgeActionSchema>;
|
||||
export type EdgeResolveResponse = z.infer<typeof edgeResolveResponseSchema>;
|
||||
export type EdgeStartRequest = z.infer<typeof edgeStartRequestSchema>;
|
||||
export type EdgeStartResponse = z.infer<typeof edgeStartResponseSchema>;
|
||||
Reference in New Issue
Block a user