Javascript SDK
Reference
verifyAccessKeyOrThrow

validatePayloadOrThrow

Validate the incoming payload and obtain a typed copy. If the payload is invalid, an error will be thrown. The method is available both as a static and as an instance method.

Parameters

  • incomingAccessKey: string - The access key that is sent as part of the incoming request.

Returns

  • true | Error

Example

import { LlamaWorkspace } from "llamaworkspace";
 
// app is an instance of express, koa, hono or any other web framework
app.post("/", async (req) => {
  const body = await req.body();
  const typedBody = LlamaWorkspace.validatePayloadOrThrow(body);
 
  // Verify that the accessKey is valid
  llamaWorkspace.verifyAccessKeyOrThrow(accessKey);
 
  // ...other code...
});