Basic routing
Routing is very simple in Routine just like it is in Express , but without the extra bloat
There are 5 http verb methods available to be used
get , post , put , patch & delete
All of the above accept same amount of parameters,
A path string such as
/xyzComma separated handlers such as
app.get(`/xyz`, (req, res) => {
//route functionality
})The last route function is called
main route handlerand any number of functions before it are calledmiddlewaresinfoThe concept of
middlewaresinRoutineis same as it is inExpress, But it has some extra functionality present in themIf you are not familiar with this concept, don’t worry, we’ll understand the workings of
middlewarelater in the docsFor now, let’s just focus on simple routing
Inside the handler you have the full power of Nodejs available to you with some extra methods, such as .json and .status
app.get(`/xyz`, (req, res) => {
//This will send a response to client and end the response cycle
res.status(200).json({
hello: 'world?',
})
//This is same as above code, but shorter
//res.json({
// "hello": "world?"
//})
})
And the above code will work with all other http verbs mentioned at the start 😀