#File System Routing
File System Routing is simply routing as per your folder structure. But it's kind of different here. In Exhancer what you do is create your root directory to watch for the routing.
Let's start
#Setting up project
#Installing Dependencies
After installing dependencies create a new file index.js
index.js
Here on line 10, where we initialize our app, we set the directory to the src folder. That means aur exhancer app will look for routes in that directory. Now the folders inside the src folder needs to be well organized in a predefined way.
#Creating folder structure.
- Create a new folder
helloinside thesrcfolder. - Inside the
hellofolder create aindex.jsfile.
You have to follow this pattern in every routes you create inside the src folder. If you get stuck following this guide go ahead and see this repo.
#Running your application.
You'll now able to make api requests to endpoint. /api/hello
Similarly, for user api you have to create a user folder within the src folder and a index.js file inside the user folder. i.e src/user/index.js