feat: initial work on stores
Some checks failed
TrafficCue Server CI / check (push) Failing after 27s
TrafficCue Server CD / build (push) Successful in 1m40s

This commit is contained in:
2025-09-22 20:14:32 +02:00
parent a2f30118ef
commit ef3debcdb3
8 changed files with 283 additions and 4 deletions

44
src/stores.ts Normal file
View File

@ -0,0 +1,44 @@
import z from "zod";
import type { StoreType } from "./entities/Stores";
export const locationStore = z.object({
lat: z.number().min(-90).max(90),
lng: z.number().min(-180).max(180),
name: z.string().min(1).max(100)
}).strict();
export const vehicleStore = z.object({
name: z.string().min(1).max(100),
legalMaxSpeed: z.number().min(0).max(300),
actualMaxSpeed: z.number().min(0).max(300),
type: z.enum([
"car", "truck", "motorcycle", "bicycle", "motor_scooter"
]),
weight: z.number().min(0).max(100000).optional(),
width: z.number().min(0).max(10).optional(),
axisLoad: z.number().min(0).max(100000).optional(),
height: z.number().min(0).max(20).optional(),
length: z.number().min(0).max(100).optional(),
emissionClass: z.string().min(1).max(50),
fuelType: z.enum(["petrol", "diesel", "electric"]),
preferredFuel: z.string().min(1).max(50)
}).strict();
export const routeStore = z.object({
locations: z.array(z.object({
lat: z.number().min(-90).max(90),
lon: z.number().min(-180).max(180)
})),
legs: z.array(z.object({
shape: z.string(),
maneuvers: z.array(z.object({
type: z.number()
}))
}))
})
export const storeTypes: Record<StoreType, z.ZodSchema> = {
location: locationStore,
vehicle: vehicleStore,
route: routeStore,
};