orpc-file-based-router 0.0.7 → 0.0.8
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.
- package/README.md +0 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,29 +25,6 @@ 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
|
-
|
|
51
28
|
### File Structure Example
|
|
52
29
|
|
|
53
30
|
```
|
package/package.json
CHANGED