addRoute()
Signature
Section titled “Signature”app.addRoute(path, handlers)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
path | string | Route path (e.g., '/', '/users'). |
handlers | Function | Object | Array | Handler(s) for the route. |
Patterns
Section titled “Patterns”Simple GET
Section titled “Simple GET”app.addRoute("/hello", (req, res) => { res.send("Hello World");});Method Mapping
Section titled “Method Mapping”app.addRoute("/users", { get: (req, res) => { /* list */ }, post: (req, res) => { /* create */ }});Supported: get, post, put, delete, patch, all.
Middleware Chains
Section titled “Middleware Chains”app.addRoute("/dashboard", { get: [authMiddleware, (req, res) => { res.send("Secure"); }]});Nested Sub-routes
Section titled “Nested Sub-routes”app.addRoute("/api", { get: (req, res) => res.send("API Root"), "/status": { get: (req, res) => res.json({ status: "ok" }) }});