File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Ecosystem Tests
2+
3+ This folder contains minimal tests for the Langbase SDK across different JavaScript runtimes and environments.
4+
5+ ## How to Test Each Ecosystem
6+
7+ ### Node.js (ESM)
8+ 1 . ` cd node-esm `
9+ 2 . ` npm install `
10+ 3 . ` node index.mjs `
11+
12+ ### Node.js (CJS)
13+ 1 . ` cd node-cjs `
14+ 2 . ` npm install `
15+ 3 . ` node index.cjs `
16+
17+ ### Bun
18+ 1 . ` cd bun `
19+ 2 . ` bun install `
20+ 3 . ` bun run index.ts `
21+
22+ ### Deno
23+ 1 . ` cd deno `
24+ 2 . Make sure you have Deno installed: https://deno.com/manual/getting_started/installation
25+ 3 . Run: ` deno run --allow-net index.ts `
26+ - If you see type errors in your editor, see comments at the top of ` index.ts ` .
27+
28+ ### Cloudflare Worker
29+ 1 . ` cd cf-worker `
30+ 2 . ` npm install `
31+ 3 . Deploy or run locally using a tool like [ ` wrangler ` ] ( https://developers.cloudflare.com/workers/wrangler/ ) :
32+ - ` wrangler dev index.ts `
33+
34+ ---
35+
36+ - Make sure to set your ` LANGBASE_API_KEY ` (or replace ` 'YOUR_API_KEY' ` in the code) for tests that require authentication.
37+ - Each subfolder contains a ` README.md ` with more specific instructions if needed.
Original file line number Diff line number Diff line change 1+ # Bun Ecosystem Test
2+
3+ This test runs a minimal workflow using ` langbase@1.2.0 ` in a Bun environment.
4+
5+ ## How to Run
6+
7+ - Make sure you have Bun installed: https://bun.sh/docs/installation
8+ - Install dependencies: ` bun install `
9+ - Run: ` bun run index.ts `
Original file line number Diff line number Diff line change 1+ import { Langbase , Workflow } from 'langbase' ;
2+
3+ async function main ( ) {
4+ const langbase = new Langbase ( {
5+ apiKey : 'YOUR_API_KEY' , // Replace with actual API key or env var
6+ } ) ;
7+ const workflow = new Workflow ( { debug : true , langbase} ) ;
8+ const result = await workflow . step ( {
9+ id : 'hello' ,
10+ run : async ( ) => 'world' ,
11+ } ) ;
12+ console . log ( { result} ) ;
13+ }
14+
15+ main ( ) . catch ( console . error ) ;
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " bun-test" ,
3+ "version" : " 1.0.0" ,
4+ "type" : " module" ,
5+ "private" : true ,
6+ "dependencies" : {
7+ "langbase" : " 1.2.0"
8+ }
9+ }
Original file line number Diff line number Diff line change 1+ # CF Worker Ecosystem Test
2+
3+ This test runs a minimal workflow using ` langbase@1.2.0 ` in a Cloudflare Worker environment.
4+
5+ ## How to Run
6+
7+ - Install dependencies: ` npm install `
8+ - Deploy or run locally using a tool like ` wrangler ` .
9+
10+ The entrypoint is ` index.ts ` .
Original file line number Diff line number Diff line change 1+ import { Langbase , Workflow } from 'langbase' ;
2+
3+ export default {
4+ async fetch ( request : Request ) {
5+ // Instantiate Langbase
6+ const langbase = new Langbase ( {
7+ apiKey : 'YOUR_API_KEY' , // Replace with actual API key or env var
8+ } ) ;
9+ // Create workflow with langbase instance
10+ const workflow = new Workflow ( { debug : true , langbase} ) ;
11+ const result = await workflow . step ( {
12+ id : 'hello' ,
13+ run : async ( ) => 'world' ,
14+ } ) ;
15+ return new Response ( JSON . stringify ( { result} ) , {
16+ headers : { 'content-type' : 'application/json' } ,
17+ } ) ;
18+ } ,
19+ } ;
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " cf-worker-test" ,
3+ "version" : " 1.0.0" ,
4+ "type" : " module" ,
5+ "private" : true ,
6+ "dependencies" : {
7+ "langbase" : " 1.2.0"
8+ }
9+ }
Original file line number Diff line number Diff line change 1+ # Deno Ecosystem Test
2+
3+ This test runs a minimal workflow using ` langbase@1.2.0 ` in a Deno environment.
4+
5+ ## How to Run
6+
7+ - Make sure you have Deno installed: https://deno.com/manual/getting_started/installation
8+ - Run: ` deno run --allow-net index.ts `
9+
10+ Note: Deno does not use ` package.json ` . You must use an npm specifier or import map to use npm packages.
Original file line number Diff line number Diff line change 1+ // If you are using the Deno VSCode extension or Deno CLI for type checking, the following line enables Deno global types:
2+ // /// <reference types="deno.ns" />
3+ // If you see 'Cannot find type definition file for deno.ns', you can safely remove the line above unless you are using Deno tooling.
4+ // Deno will run this file fine without it.
5+ // @deno -types="npm:langbase@1.2.0"
6+ import { Langbase , Workflow } from 'npm:langbase@1.2.0' ;
7+
8+ async function main ( ) {
9+ const langbase = new Langbase ( {
10+ apiKey : Deno . env . get ( 'LANGBASE_API_KEY' ) ?? 'YOUR_API_KEY' ,
11+ } ) ;
12+ const workflow = new Workflow ( { debug : true , langbase} ) ;
13+ const result = await workflow . step ( {
14+ id : 'hello' ,
15+ run : async ( ) => 'world' ,
16+ } ) ;
17+ console . log ( { result} ) ;
18+ }
19+
20+ main ( ) . catch ( console . error ) ;
Original file line number Diff line number Diff line change 1+ # Node.js CJS Ecosystem Test
2+
3+ This test runs a minimal workflow using ` langbase@1.2.0 ` in a Node.js CommonJS environment.
4+
5+ ## How to Run
6+
7+ - Install dependencies: ` npm install `
8+ - Run: ` node index.cjs `
You can’t perform that action at this time.
0 commit comments