About Routers
A router in JStack is a collection of procedures (API endpoints) related to a specific feature or resource. For example:
userRouterfor user management operationspostRouterfor blog post operationspaymentRouterfor payment related endpoints
Creating a Router
-
Create a new file in
server/routers:server/routers/post-router.ts
-
Add procedures to your router:
-
Register your router with the main
appRouter:server/index.ts
Under the hood, each procedure is a separate HTTP endpoint. The URL structure is as follows:
- The base path of your API (
/api) - The router name (
post) - The procedure name (
list)
For example, the list procedure is now available at