Pronouns: he/him
Principal R&D Engineer
Nordic Semiconductor
Trondheim, Norway
@sinclair/typebox
TypeCompiler
(~2x faster than AJV)Code demo: code/validator/validateWithTypeBox.ts
const maybeCellGeolocation = await c.post({
resource: "location/ground-fix",
payload,
requestSchema: groundFixRequestSchema,
responseSchema: locateResultSchema,
});
if ("error" in maybeCellGeolocation) {
return { located: false };
}
const { lat, lng, uncertainty } = maybeCellGeolocation;
return { lat, lng, accuracy: uncertainty, located: true };
validatingFetch()
for JSXCode demo: code/preact/SIMUsageHistory.tsx
import {
validateInput,
type ValidInput,
} from "@hello.nrfcloud.com/lambda-helpers/validateInput";
import { validateResponse } from "@hello.nrfcloud.com/lambda-helpers/validateResponse";
import middy from "@middy/core";
import { Type } from "@sinclair/typebox";
import type { Context } from "aws-lambda";
const InputSchema = Type.Object({});
export const handler = middy()
.use(validateInput(InputSchema))
.use(validateResponse(Type.Object({})))
.handler(async (_, context: ValidInput<typeof InputSchema> & Context) => {
// ...
});
example: validateInput · validateResponse
Alternatives?