Routing in BushJS (HTTP):
BushJS has a very easy and simple way to handle routing.
For basic routes, you can use:
app.get(path, handler)
app.post(path, handler)
path → the route URL (e.g. /users)
handler → the function that runs when the route is called
But HTTP has more methods than just GET and POST.
To use all methods, you can access the router:
app.router.get(path, handler)
app.router.post(path, handler)
app.router.put(path, handler)
app.router.delete(path, handler)
app.router.any(path, handler)
app.router.resource(name, controller)
app.router.apiResource(name, controller)
Example
app.get('/users', (req, res) => {
res.send('All users')
})

Top comments (0)