Routing refers to determining how an application responds to a client request to a particular endpoint, which is a URI (or path) and a specific HTTP request method (GET, POST, and so on).
Each route can have one or more handler functions, which are executed when the route is matched.
Route definition takes the following structure.
All routes are defined in your route files, which are located in the routes directory.
These files are automatically mapped by Express Sweet to the route files specified in the URI and the route handlers defined in the route files.
The following examples illustrate defining simple routes. routes/user.js responds to GET /user requests.
The router supports nested files.
If you create a nested folder structure files will be automatically routed in the same way still. routes/api/users.js responds to GET /api/users requests.
Express Sweet can be told to load a default router when a URI is not present, as will be the case when only your site root URL (/) is requested.
To specify a default router, open your config/config.js file and set this variable:
default_router: '/blog'
Where blog is the name of the router module you want used.
Next, create the routes/blog.js module.
Now when you request the root URL (/), you will see "Hello World".
Routing Methods
Express supports the following routing methods corresponding to the HTTP methods of the same names.
For more details about routing, see the Exprees’s Routing Guide.