Learn how to use Node.js, FastifyJS and HarperDB by building a course management REST API. This application will help you track the courses you are doing and the courses you plan to do.
- Set up the folder structure by creating a new folder called "course-management" and initializing a new Node.js project within it using the command "npm init -y."
- Install the required dependencies for the application using the command "npm i fastify harperive dotenv --save."
- Configure the Fastify server by creating an "app.js" file and adding the necessary code to set up the server, including importing Fastify, enabling the logger, and listening on a specified port defined in the ".env" file.
- Create a HarperDB Cloud Instance and configure it by setting up a schema and table to store course data.
- Set up the HarperDB client in the application by creating a "db_config.js" file in the "src/db" folder and initializing the HarperDB client with the instance details from the ".env" file.
- Create and configure the application endpoints by creating the necessary folders and files for routes and controllers.
- Build the logic for each endpoint using the HarperDB client to perform CRUD operations on the database.
- Test the application by starting the server using the command "node app.js" and accessing the different endpoints through HTTP requests.
- Optionally, clone the application from GitHub, install the dependencies using "npm install," and start the server with "node app.js" to run the application.