@@ -19,10 +19,6 @@ t-req keeps standard <code>.http</code> files as the source of truth and lets yo
1919 <b ><a href =" https://t-req.io " >Docs</a ></b > · ; <b ><a href =" https://discord.gg/sKY4M3eS " >Discord</a ></b >
2020</p >
2121
22- <p align =" center " >
23- <img src =" ./docs/assets/tui.gif " alt =" t-req TUI " >
24- </p >
25-
2622## Install
2723
2824``` bash
@@ -43,33 +39,101 @@ But a file format alone doesn't get you far. t-req is the engine that makes `.ht
4339
4440One source of truth, many surfaces. The same ` .http ` file runs from the terminal, a server, a test suite, or a TypeScript script.
4541
46- ## Run from the Terminal
42+ ## Run from CLI
43+
44+ Use direct CLI commands in any terminal:
4745
4846``` bash
4947treq init my-api && cd my-api
50- treq open # interactive TUI
5148treq run requests/users/list.http # single request from CLI
5249```
5350
54- ## Run from VS Code
51+ ## Run from the terminal app
52+
53+ Use the interactive terminal app to browse files, run requests, and inspect results:
54+
55+ ``` bash
56+ treq open
57+ ```
58+
59+ ![ t-req TUI demo] ( https://assets.t-req.ai/tui-demo.gif )
60+
61+ ## Run from VS Code or Cursor
62+
63+ Install the [ t-req extension] ( ./packages/vscode ) in VS Code or Cursor for syntax highlighting, inline execution, and assertion results (` @t-req/plugin-assert ` ) directly in your editor.
64+
65+ [ ![ t-req init in VS Code or Cursor] ( https://assets.t-req.ai/treq-init-cursor.gif )] ( https://assets.t-req.ai/treq-demo-desktop.mp4 )
66+
67+ ## Run from Web
68+
69+ Start the web app directly from your workspace:
70+
71+ ``` bash
72+ treq web
73+ ```
74+
75+ <p align =" center " >
76+ <img src =" ./docs/assets/web.png " alt =" t-req web dashboard " >
77+ </p >
78+
79+ ## Embed in Scripts, Tests, or CI
5580
56- Install the [ t-req extension] ( ./packages/vscode ) for syntax highlighting, inline execution, and assertion results (@t-req/plugins-assert ) directly in the editor.
81+ ` @t-req/core ` lets you execute the same ` .http ` files from scripts, test suites, and automation jobs.
82+ This is the core idea: one request collection, many execution surfaces.
5783
58- ![ VS Code assertions] ( ./docs/assets/vscode-assertions.png )
84+ ``` typescript
85+ import { createClient } from ' @t-req/core' ;
86+
87+ const client = createClient ({
88+ variables: { baseUrl: ' https://dummyjson.com' }
89+ });
90+
91+ // 1) Login from a .http file
92+ const loginRes = await client .run (' ./examples/core/e-commerce/auth/login.http' , {
93+ variables: { username: ' emilys' , password: ' emilyspass' }
94+ });
95+
96+ if (! loginRes .ok ) throw new Error (` Login failed: ${loginRes .status } ` );
97+
98+ const login = await loginRes .json ();
99+ client .setVariable (' token' , login .accessToken );
100+ client .setVariable (' userId' , login .id );
101+
102+ // 2) Reuse variables in another .http file
103+ const profileRes = await client .run (' ./examples/core/e-commerce/users/profile.http' );
104+ if (! profileRes .ok ) throw new Error (` Profile lookup failed: ${profileRes .status } ` );
105+
106+ const profile = await profileRes .json ();
107+ console .log (` ${profile .firstName } <${profile .email }> ` );
108+ ```
109+
110+ For a larger end-to-end example, see [ ` examples/core/e-commerce/checkout-flow.ts ` ] ( ./examples/core/e-commerce/checkout-flow.ts ) .
59111
60- ## Run from TypeScript
112+ ## Test with Any Framework
61113
62- ` @ t-req/core ` is a standalone library. Parse, execute, and inspect requests from your own code .
114+ t-req works with your existing runner ( ` bun:test ` , Vitest, Jest, or ` node:test ` ) because tests call ` client.run(...) ` the same way .
63115
64116``` typescript
117+ import { describe , expect , test } from ' vitest' ;
65118import { createClient } from ' @t-req/core' ;
66119
67120const client = createClient ({
68- variables: { token: process . env . API_TOKEN },
121+ variables: { baseUrl: ' https://jsonplaceholder.typicode.com ' }
69122});
70123
71- const response = await client .run (' ./auth/login.http' );
72- const { user } = await response .json ();
124+ describe (' collection/users/list.http' , () => {
125+ test (' returns a list of users' , async () => {
126+ const response = await client .run (' ./collection/users/list.http' );
127+
128+ expect (response .status ).toBe (200 );
129+ });
130+ });
131+ ```
132+
133+ ``` bash
134+ # run with your existing test command
135+ npm test
136+ # or: pnpm test / bun test / vitest / jest / node --test
73137```
74138
75139## Plugin Pipeline
@@ -138,13 +202,9 @@ curl -X POST http://localhost:4097/execute \
138202- ** Command resolvers** — ` {{$timestamp()}} ` , ` {{$uuid()}} ` , or your own custom functions
139203- ** Cookie management** — automatic jar with RFC 6265 compliance
140204- ** SSE streaming** — ` @sse ` directive for Server-Sent Events
141- - ** Web dashboard** — ` treq open -- web ` for a browser-based UI
205+ - ** Web dashboard** — run with ` treq web `
142206- ** TypeScript-first** — full type definitions, async/await, ` AsyncDisposable ` support
143207
144- <p align =" center " >
145- <img src =" ./docs/assets/web.png " alt =" t-req web dashboard " >
146- </p >
147-
148208> ** Open source. MIT licensed. No cloud account required.**
149209
150210## Packages
@@ -157,7 +217,7 @@ curl -X POST http://localhost:4097/execute \
157217| [ @t-req/sdk ] ( ./packages/sdk/js ) | TypeScript SDK for the server |
158218| [ @t-req/plugin-base ] ( ./packages/plugins/base ) | Built-in resolvers (uuid, timestamp, base64, etc.) |
159219| [ @t-req/plugin-assert ] ( ./packages/plugins/assert ) | Assertion directives for ` .http ` files |
160- | [ t-req for VS Code] ( ./packages/vscode ) | VS Code extension with inline execution and assertions |
220+ | [ t-req for VS Code/Cursor ] ( ./packages/vscode ) | VS Code-compatible extension with inline execution and assertions |
161221
162222## Contributing
163223
0 commit comments