The above command will generate a tsconfig.json file with some default configurations. – Has the TypeScript definitions for Node.js.ts-node-dev – To hot-reload the server upon every file change.typescript – To use the tsc command in the project.Npm install -D typescript ts-node-dev & npx tsc -init Yarn add -D typescript ts-node-dev & yarn tsc -init Next, install these dependencies to add TypeScript to the Node.js project: "description": "Explore Prisma Tutorial", This creates a package.json file with an initial setup for the TypeScript Node.js app. Press the ENTER key to accept the default values and don’t forget to set the entry point file to server.ts. Next, you will be presented with some optional prompts to set up the project. Initialize a Node.js TypeScript ProjectĮxecute this command to create a sample Node.js application: In this step, you will initialize a TypeScript Node.js project and set up Prisma. You can stop the container with this command: Now open the integrated terminal in VS Code and start the Postgres server with this command: These credentials will be used by the Postgres image to configure the Postgres server. env file with the following environment variables. We also created a named volume postgres to prevent data loss when deleting the Postgres container.Ĭreate a. We mapped our local port 6500 to the Postgres default port 5432 to allow us to connect and interact with the running PostgreSQL server outside the Docker container. Now create a docker-compose.yml file in the root folder and add the following configurations to help us manage the PostgreSQL instance on our machine. Once the folder has been created, open it with VS Code. In this example, you can use explore-prisma. To do that, first, create a project folder. Step 1 – Create a Sample PostgreSQL DatabaseĪs part of the prerequisites, you should have a running PostgreSQL server, however, we will create a Postgres instance using Docker and Docker-compose. The Prisma migrate tool takes the models defined in the schema file and generates a history of .sql migration files as well as types that are stored in a node_modules/.prisma/client folder. Prisma Studio: A visual editor ( GUI) to view and modify data in your database.Prisma Migrate: This is an imperative database schema migration tool that keeps the database schema in sync with the defined Prisma schema.Prisma Client: This is an auto-generated and type-safe query builder used for reading data, writing data, and performing advanced patterns like creating transactions, raw queries, logging, and middleware.This tutorial was tested on Node.js version 16.14.0 and Yarn version 1.22.19 on Windows 11 computer. I recommend VS Code because it provides tools and extensions for developing applications in many programming languages. It’s optional since we will be using Docker.
0 Comments
Leave a Reply. |