Giter VIP home page Giter VIP logo

basic-nest's Introduction

SIMPLE NEST.JS TASK API WITH SWAGGER AND JWT AUTH

Overview

SIMPLE NEST.JS TASK API WITH SWAGGER AND JWT AUTH.

Requirements

  • Node.js(version 18 upward)
  • Docker
  • npm

Setup Instructions

1. Clone the Repository

git clone https://github.com/LexxLuey/basic-nest
cd basic-nest

2. Start PostgreSQL Container

Make sure Docker is installed and running on your system. Then, execute the following command to start the PostgreSQL container using Docker Compose:

docker-compose up -d

This command will pull the PostgreSQL image and create a container named postgres with the specified configuration in docker-compose.yml.

3. Install Dependencies

Install the project dependencies using npm:

npm install

4. Set up Prisma

4.1 Install Prisma CLI

If you haven't installed the Prisma CLI globally, you can install it using npm:

npm install -g prisma

Follow the prompts and choose the PostgreSQL database option. Provide the required database connection details.

4.2 Create Database Schema

Define your database schema in schema.prisma file according to your project requirements. This has already been done for Task and User models.


Usage

Running the NestJS Application in Development Mode

To run the NestJS application in development mode, follow these steps:

  1. Start PostgreSQL Container: Ensure Docker is installed and running on your system. Run the following command to start the PostgreSQL container using Docker Compose (If you have done this already, SKIP):
docker-compose up -d
  1. Set Environment Variables: Create a .env file in the root directory of the project if it doesn't already exist. Define the following environment variables:
DATABASE_URL=postgresql://<username>:<password>@localhost:5432/<database_name>
JWT_SECRET=<your_jwt_secret_key>

Replace <username>, <password>, and <database_name> with your PostgreSQL database credentials and database name. Choose a secure value for JWT_SECRET.

  1. Install Dependencies: Install the project dependencies using npm:
npm install
  1. Run Prisma Migration: Generate and apply Prisma migrations by running the following commands:

Generate the Prisma Client by running the following command:

prisma generate

Then apply migrations:

npx prisma migrate dev --name "init"

This command will create the necessary tables in your PostgreSQL database based on your Prisma schema.

  1. Start the NestJS Application: Once the PostgreSQL container is running, the Prisma migrations are applied, and the dependencies are installed, you can start the NestJS application:
npm run start:dev

This command will start the NestJS application in development mode. By default, the application will listen on port 5000.

  1. Access the Application: You can now access the NestJS application by navigating to http://localhost:5000/api in your web browser.

Contributing

License

Acknowledgements


basic-nest's People

Contributors

lexxluey 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.