Files
source-gamepanel/apps/api/src/routes/nodes/schemas.ts
T
2026-02-21 13:37:46 +03:00

44 lines
1.7 KiB
TypeScript

import { Type } from '@sinclair/typebox';
export const NodeParamSchema = {
params: Type.Object({
orgId: Type.String({ format: 'uuid' }),
nodeId: Type.String({ format: 'uuid' }),
}),
};
export const CreateNodeSchema = {
body: Type.Object({
name: Type.String({ minLength: 1, maxLength: 255 }),
fqdn: Type.String({ minLength: 1, maxLength: 255 }),
daemonPort: Type.Optional(Type.Number({ minimum: 1, maximum: 65535, default: 8443 })),
grpcPort: Type.Optional(Type.Number({ minimum: 1, maximum: 65535, default: 50051 })),
location: Type.Optional(Type.String({ maxLength: 255 })),
memoryTotal: Type.Number({ minimum: 0 }),
diskTotal: Type.Number({ minimum: 0 }),
memoryOveralloc: Type.Optional(Type.Number({ minimum: 0, default: 0 })),
diskOveralloc: Type.Optional(Type.Number({ minimum: 0, default: 0 })),
}),
};
export const UpdateNodeSchema = {
body: Type.Object({
name: Type.Optional(Type.String({ minLength: 1, maxLength: 255 })),
fqdn: Type.Optional(Type.String({ minLength: 1, maxLength: 255 })),
daemonPort: Type.Optional(Type.Number({ minimum: 1, maximum: 65535 })),
grpcPort: Type.Optional(Type.Number({ minimum: 1, maximum: 65535 })),
location: Type.Optional(Type.String({ maxLength: 255 })),
memoryTotal: Type.Optional(Type.Number({ minimum: 0 })),
diskTotal: Type.Optional(Type.Number({ minimum: 0 })),
memoryOveralloc: Type.Optional(Type.Number({ minimum: 0 })),
diskOveralloc: Type.Optional(Type.Number({ minimum: 0 })),
}),
};
export const CreateAllocationSchema = {
body: Type.Object({
ip: Type.String({ minLength: 1, maxLength: 45 }),
ports: Type.Array(Type.Number({ minimum: 1, maximum: 65535 }), { minItems: 1 }),
}),
};