Skip to content

Commit 896e4a0

Browse files
📦 NEW: Ecosystem tests (#111)
* 📦 NEW: cf worker * 📦 NEW: node cjs * 📦 NEW: node esm * 📦 NEW: Bun * 📦 NEW: Deno * 🐛 FIX: instantiation * 👌 IMPROVE: Deno * 📦 NEW: Readme
1 parent 78e23ba commit 896e4a0

File tree

15 files changed

+202
-0
lines changed

15 files changed

+202
-0
lines changed

ecosystem-tests/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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.

ecosystem-tests/bun/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Bun Ecosystem Test
2+
3+
This test runs a minimal workflow using `[email protected]` 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`

ecosystem-tests/bun/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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);

ecosystem-tests/bun/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# CF Worker Ecosystem Test
2+
3+
This test runs a minimal workflow using `[email protected]` 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`.

ecosystem-tests/cf-worker/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
}

ecosystem-tests/deno/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Deno Ecosystem Test
2+
3+
This test runs a minimal workflow using `[email protected]` 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.

ecosystem-tests/deno/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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:[email protected]"
6+
import {Langbase, Workflow} from 'npm:[email protected]';
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);

ecosystem-tests/node-cjs/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Node.js CJS Ecosystem Test
2+
3+
This test runs a minimal workflow using `[email protected]` in a Node.js CommonJS environment.
4+
5+
## How to Run
6+
7+
- Install dependencies: `npm install`
8+
- Run: `node index.cjs`

0 commit comments

Comments
 (0)