orpc-file-based-router 0.0.6 → 0.0.7

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 +25 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A plugin for [oRPC](https://orpc.unnoq.com) that automatically creates an oRPC router configuration based on your file structure.
4
4
 
5
- > ⚠️ **IMPORTANT:** Works only at nodejs runtime
5
+ > ⚠️ **IMPORTANT:** At this time, the plugin's functionality is only guaranteed in nodejs runtime
6
6
 
7
7
  ## Installation
8
8
 
@@ -25,6 +25,29 @@ const router = await generateRouter(routesDir, outputFile)
25
25
  const handler = new RPCHandler(router)
26
26
  ```
27
27
 
28
+ Alternative approach for environments without top-level await support:
29
+
30
+ ```typescript
31
+ import { RPCHandler } from '@orpc/server/node'
32
+ import { generateRouter } from 'orpc-file-based-router'
33
+
34
+ async function setupRouter() {
35
+ const routesDir = new URL('./routes', import.meta.url).pathname
36
+ const outputFile = new URL('./router.ts', import.meta.url).pathname
37
+ const router = await generateRouter(routesDir, outputFile)
38
+
39
+ return new RPCHandler(router)
40
+ }
41
+
42
+ // Initialize the router
43
+ setupRouter().then(handler => {
44
+ // Your application code here
45
+ console.log('Router initialized and ready to use')
46
+ }).catch(error => {
47
+ console.error('Failed to initialize router:', error)
48
+ })
49
+ ```
50
+
28
51
  ### File Structure Example
29
52
 
30
53
  ```
@@ -78,4 +101,4 @@ export const router = {
78
101
 
79
102
  ## License
80
103
 
81
- MIT
104
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orpc-file-based-router",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "File-based router plugin for oRPC - automatically generate oRPC router from your file structure",
5
5
  "author": "zeeeeby",
6
6
  "license": "MIT",