Skip to content
This repository was archived by the owner on Aug 19, 2026. It is now read-only.

Repository files navigation

@herd-labs/trails-code-framework

A framework for building custom Code Nodes in Herd Trails. This package provides the tools and utilities needed to create Deno scripts that can transform data, make web requests, and perform custom logic within your Trail workflow.

Installation

// Use directly in your Herd Deno scriptimport{initializeHerdCodeServer,EVMAddress,Bytes}from"npm:@herd-labs/trails-code-framework";

Quick Start

Below is an example Deno script that makes use of the Trails Code Framework:

import{initializeHerdCodeServer}from"npm:@herd-labs/trails-code-framework";import{z}from"npm:zod";// Define your input and output schemas using Zod. These can be named anything, we currently do not support arrays or nested objects (tuples).constinputSchema=z.object({a: z.number(),b: z.number(),});constoutputSchema=z.object({sum: z.number(),});// Create your main function (can be named anything, use z.infer to type your inputs/outputs)asyncfunctionhandler(input: z.infer<typeofinputSchema>): Promise<z.infer<typeofoutputSchema>>{return{sum: input.a+input.b,};}// This default export initializes the Trails Code Framework on DenoexportdefaultinitializeHerdCodeServer(inputSchema,outputSchema,handler);

API Reference

Core Functions

initializeHerdCodeServer(inputSchema, outputSchema, handler)

Creates a validated HTTP endpoint with automatic request/response validation.

Parameters:

  • inputSchema: Zod schema for input validation
  • outputSchema: Zod schema for output validation
  • handler: Function that processes the validated input and returns the output

Returns: Herd-compliant code ready for use in a Trail!

License

TBD

About

NPM package used for creating Herd Trail Code Nodes

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages