The response data to validate
Type predicate indicating if the data is a valid TimestampResponse
const response = await fetch("/api/timestamp");
const data = await response.json();
if (isTimestampResponse(data.data)) {
console.log("Server time:", data.data.timestamp);
}
export function isTimestampResponse(data: unknown): data is TimestampResponse {
return v.safeParse(timestampResponseSchema, data).success;
}
Type guard to validate if data matches the Macklin timestamp response structure. The timestamp endpoint returns the server's current Unix timestamp.