![]() Just to make this project-1 easier.Īs we already installed the node-postgres package at the beginning, let's move on!Ĭreating an environment variable with 'dotenv'Īnother point that you may have noticed is that we also installed the dotenv package. In this project, I decided to use node-postgres rather than Sequelize, which is a widely used ORM for those who use PostgreSQL, MySQL, MariaDB, SQLite, and Microsoft SQL Server. I recommend reading the package documentation, which can be found here HERE. It helped me a lot to develop this tutorial! And it has simple and straightforward documentation - teaching how we can implement this package in Promises or using Async / Await. This package will be essential for us to work with the PostgreSQL Client on Node.js. You may have noticed that when we installed some packages, we included the node-postgres package. Understanding a little bit more about the package: 'node-postgres' If the screen is shown just like the one you can see above, this means our API is working correctly! Now, let's go deeper into development. We will now create the table with the properties that will be used to persist to be used in our Back-End.Įnter fullscreen mode Exit fullscreen modeĪnd then open the postman and include the following URL in (GET): localhost:3000/api/: A browser page will open on and now we can start to use it! ![]() After installing, just search for pgAdmin. In my case, I will be using Windows, since it is my main development machine. Linux: for Linux users, as there are countless different versions of Linux, I recommend you to take a look at this PostgreSQL guide HERE If you have some issues or difficulty installing, I recommend you to take a look at this video HERE Also, you will need to have Homebrew installed. MacOS: for Mac users, just download the packages HERE. Common and simple installation, as if you were installing a program on Windows. Windows: for Windows users, download Postgres for Windows. Well, I'll teach you here how to install PostgreSQL for different OS users: But also feel free to use some Docker image to continue this tutorial. We'll need to install PostgreSQL on our machine. I always liked PostgreSQL because it is very simple and easy to use! PostgreSQL was the first database that I learned to work with and it was with it that I learned in Database I and II classes in 2012 at the University. One of the things that attract many developers to use PostgreSQL is that it is completely free, available on any Operating Systems, and best of all: it is completely Open Source! Countless large companies like Uber, Netflix, Spotify, Instagram, Reddit, and many others make use of PostgreSQL. I will mention here some resources that we will use during the development of this application throughout this article. Configuring the connection string to the database in the file: 'database.js'.Creating an environment variable with 'dotenv'. ![]() Understanding a little bit more about the package: 'node-postgres'.Creating the Application Architecture in Node.js.If, when we reach the end of the project, we want to test the Back-End API created in some application in the Front-End, I can then be creating a generic Front-End just to test the created api! Important information: the focus of the project will be on the Back-End. I created a repository on GitHub HERE, where all the source code of this project and the resources that I will be mentioned during the 5 articles are allocated. After that, we will be migrating the project to serverless architecture with Azure Functions, migrating the local database to Azure PostgreSQL, and finally deploying this application using GitHub Actions. Hey all Coders! How are you doing? Today we are going to start a series of articles where we will be developing a CRUD application with Node.js & PostgreSQL focusing on the Back-End. ![]()
0 Comments
Leave a Reply. |