Contact us


Testing NodeJs and PostgreSQL Generated Code


In the last article, we discussed how to generate REST API code in NodeJs and Postgresql.

In this article, we will discuss how to test the generated code.

Our generated code contains endpoints authentication by default. Endpoint authentication is achieved through a middleware function for each endpoint. We remove the middleware and start our server. I will make a separate article on how this endpoint authentication works.

Below is our generated code with endpoint authentication


After removing endpoint authentication.

logo Create

First, we will make a post request to our server to add data to our database. If we look below at the generated code, we can see what the body of our HTTP request should be. we copy this and paste it into our thunder client window.


Thunderclient is a simpler alternative to the postman and it comes as a vs code extension.

Thunder client settings and post URL can be found in the below screenshot.


Once we have our URL and request body in place, we can make a post request. As we can see above our post request is a success. let's add a few more data to our database.


Now we have added a handful of data to our database and now it is time to make a get-all request to see if our data is there. And as we can see below our get-all request is a success and we have received all the data from our database.


If we want to get just one specific data from the database, we can pass the primary key of that data as a query. As we can see below, we have passed student_id as a query in our HTTP request to retrieve the data.

logo Update

Now it is time to update the data and to do that we need the primary key of the data to be updated, pass it as a query and we need content to be updated, which we pass in the body. If there is no need to update some of the fields, then pass it as what it is, in the request body.

We are updating the schooling_year of our Rocky from 10 to 11.


As we can see through our get request, our update is reflected.

logo Delete

Now to delete data from the database, input the URL, and pass the primary key of the data you want to delete in the request.


By making get one request with the same primary key we can see that it returns empty array and our delete operation is successful.


Talk to us...


© 2022 AutoCodeGen. All rights reserved


About usOur BlogsContact Us