Giter Site home page Giter Site logo

nest-basic-template's Introduction

Nest Backend Application

Welcome to the Nest repository.

Prerequisites

Make sure you have the following requirements installed before getting started:

  • Node.js (version ^20.15 | ^18.10)
  • pnpm (version ^9.0)

Note

To use pnpm, simply run the corepack enable command (make sure to have Node.js installed beforehand). Refer to here for more information.

Technologies Used

  • Framework: Nest JS (version ^10.0)
  • Database: Postgres (version ^16.0)

Steps to Run the Server

1. Initialize Environment Variables

Make a copy of the .env.example file in the current directory and rename it to .env.

cp .env.example .env

This file initializes environment variables containing configurations needed to start the application. These variables are as follows:

  • PORT: The port on which the server listens for connections
  • CORS_ALLOWED_ORIGINS: A list of allowed origins for CORS request
  • DB_USER: The username to connect to the database
  • DB_PASSWORD: The password to connect to the database
  • DB_HOST: The address of the host where the database is located
  • DB_PORT: The port on which the database server is listening
  • DB_NAME: The name of the database to connect
  • DATABASE_URL: The connection URL for Prisma ORM
  • JWT_SECRET: The secret key used to sign and verify JWT
  • NODE_ENV: The environment in which the application is running

2. Start the Postgres Engine

Check if Postgres is installed. If not, you can easily create it with Docker by running the command:

docker compose up -d

Note

Make sure Docker is installed to run the docker compose up -d command.

3. Install Dependencies

Install project dependencies by running the following command:

pnpm install

4. Migrate Schemas to the Database

Create the database and automatically insert test data by running the following command:

pnpm db:migrate:dev

Important

  • Ensure that the database connection string is correctly set in the DATABASE_URL variable in the .env file.
  • If test data is not inserted automatically, run the pnpm db:seed command to insert it manually.

5. Start the Backend Application

Run the server in development mode

pnpm start:dev

Run the server in production mode

pnpm start:prod

nest-basic-template's People

Contributors

amaruvl avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.