GithubHelp home page GithubHelp logo

transmissions-backend's Introduction

NestJS API with PostgreSQL and JWT Authentication

The task involved creating a Node.js-based API using NestJS that interacts with a PostgreSQL database. The API supports CRUD (create, read, update, and delete) operations, implements user authentication and authorization using JSON Web Tokens (JWTs), and includes error handling and validation.

Features

  • NestJS: This project uses NestJS, a powerful and extensible Node.js framework, to build the API.

  • PostgreSQL: The PostgreSQL database is used for storing and managing data.

  • TypeORM: TypeORM is utilized to define the data schema and interact with the PostgreSQL database.

  • JWT Authentication: JSON Web Tokens (JWTs) are implemented for user authentication and authorization.

  • Validation: Class-validator pipes are used to validate the data passed in the request body.

  • Swagger Documentation: Swagger documentation is included for clear API documentation and testing.

  • Docker for PostgreSQL: Instructions for setting up a PostgreSQL database using Docker are provided.

  • Git and GitHub: Git is used for version control, and the code is hosted on GitHub.

Prerequisites

Before running the project, ensure you have the following dependencies installed:

Getting Started

Follow these steps to run the project:

  1. Clone the repository to your local machine:

    git clone [email protected]:SubstantialCattle5/SocialMediaBackend.git
  2. Install the project dependencies:

    cd SocialMediaBackend
    yarn 
  3. Set up the PostgreSQL database using Docker:

    docker compose -up dev-db d 
  4. Create a .env file in the project root and configure the database connection:

    DB_HOST=localhost
    DB_PORT=5432
    DB_USERNAME=postgres
    DB_PASSWORD=postgres
    DB_DATABASE=postgres
  5. Start the NestJS application:

    yarn run start:dev
  6. The API should now be running locally. You can access the Swagger documentation at http://localhost:3000/docs to explore and test the API endpoints.

API Endpoints

Auth

  • POST /auth/register: Register a new user.
  • POST /auth/login: Log in and receive a JWT token.

Tweet

  • GET /tweet: Get a list of all tweets.
  • GET /tweet/:id: Get a single tweet by ID.
  • POST /tweet: Create a new tweet (requires authentication).
  • PUT /tweet/:id: Update an existing tweet (requires authentication).
  • DELETE /tweet/:id: Delete a tweet (requires authentication).

Usage

  1. Register a new user using the /auth/register endpoint. Swagger doc
  2. Log in with the registered user using the /auth/login endpoint to obtain a JWT token. Swagger docw
  3. Use the JWT token for authenticated requests to create, update, or delete tweets. Alt text
  4. Use the /tweet endpoints to interact with tweet data.

transmissions-backend's People

Contributors

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