ts-procedures 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +31 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -312,15 +312,42 @@ const { Create } = Procedures<{ req: Request; res: Response }>({
312
312
  // Procedures are automatically registered as /rpc/GetUser, /rpc/CreateUser, etc.
313
313
  ```
314
314
 
315
- ### Express Utility
315
+ ### Express RPC Integration
316
316
 
317
- `ts-procedures` includes a built-in Express integration that handles route registration, parameter extraction, and validation automatically.
317
+ `ts-procedures` includes an RPC-style HTTP integration for Express that creates POST routes at `/rpc/{name}/{version}` paths with automatic JSON schema documentation.
318
318
 
319
319
  ```typescript
320
- import { registerExpressRoutes } from 'ts-procedures/express'
320
+ import { ExpressRPCAppBuilder, RPCConfig } from 'ts-procedures/express-rpc'
321
+
322
+ // Create procedure factory with RPC config
323
+ const RPC = Procedures<AppContext, RPCConfig>()
324
+
325
+ // Define procedures with name and version
326
+ RPC.Create(
327
+ 'GetUser',
328
+ {
329
+ name: ['users', 'get'],
330
+ version: 1,
331
+ schema: {
332
+ params: Type.Object({ id: Type.String() }),
333
+ returnType: Type.Object({ id: Type.String(), name: Type.String() }),
334
+ },
335
+ },
336
+ async (ctx, params) => {
337
+ return { id: params.id, name: 'John Doe' }
338
+ }
339
+ )
340
+
341
+ // Build Express app with registered procedures
342
+ const app = new ExpressRPCAppBuilder()
343
+ .register(RPC, (req) => ({ userId: req.headers['x-user-id'] as string }))
344
+ .build()
345
+
346
+ app.listen(3000)
347
+ // Route created: POST /rpc/users/get/1
321
348
  ```
322
349
 
323
- See [Express Integration Guide](src/implementations/http/express/README.md) for complete setup instructions.
350
+ See [Express RPC Integration Guide](src/implementations/http/express-rpc/README.md) for complete setup instructions including lifecycle hooks, error handling, and route documentation.
324
351
 
325
352
  ### Introspection with getProcedures()
326
353
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-procedures",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "A TypeScript RPC framework that creates type-safe, schema-validated procedure calls with a single function definition. Define your procedures once and get full type inference, runtime validation, and framework integration hooks.",
5
5
  "main": "build/exports.js",
6
6
  "types": "build/exports.d.ts",