Skip to content

This API allows authenticated users to create, read, update, and delete heroes stored in MongoDB, with user authentication via PostgreSQL. Built with test coverage, it ensures data security and quality. The tech stack includes Node.js, Hapi, JWT, and Mocha.

Notifications You must be signed in to change notification settings

victorsfranco/heroes-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Heroes API

Overview

This project is a API built to manage a collection of heroes. It allows authenticated users to perform CRUD operations (Create, Read, Update, and Delete) on a MongoDB database. User authentication and authorization are handled via a PostgreSQL database.

The API is designed with a focus on scalability, security, and maintainability, ensuring that only authenticated users can manage the data. It is fully tested with high code coverage, guaranteeing the quality and reliability of the application.

Features ✨

  • CRUD Operations: Create, Read, Update, and Delete heroes.
  • Authentication: Secure user authentication using PostgreSQL.
  • MongoDB Integration: Heroes are stored and managed in a MongoDB database.
  • Test Coverage: Comprehensive test suite ensuring high-quality code.
  • Scalable: Built to handle large datasets and numerous users.

Tech Stack 👾

  • Node.js: JavaScript runtime.
  • MongoDB: For storing hero data.
  • PostgreSQL: For user authentication.
  • Mocha: For unit and integration tests.
  • JWT: For securing API endpoints.
  • Hapi: Web framework for routing and middleware.
  • Swagger: Documentation.

Setup and Installation 🖥️

  1. Clone the repository:

    git clone git@github.com:victorsfranco/heroes-api.git
  2. Install dependencies:

    npm install
  3. Configure environment variables for MongoDB, PostgreSQL, and JWT.

  4. Run docker containers:

  • Client for PostgreSQL

    docker run \
     --name postgres \
     -e POSTGRES_USER=myUser \
     -e POSTGRES_PASSWORD=mySecretPassword \
     -e POSTGRES_DB=heroes \
     -p 5432:5432 \
     -d \
     postgres
    
    docker exec -it postgres /bin/bash
  • Client for PostgreSQL

docker run \
 --name adminer \
 -p 9090:8080 \
 --link postgres \
 -d \
 adminer
  • MongoDB
docker run \
 --name mongodb \
 -p 27017:27017 \
 -e MONGO_INITDB_ROOT_USERNAME=admin \
 -e MONGO_INITDB_ROOT_PASSWORD=mySecretPassword \
 -d \
 mongo:4
  • Client for MongoDB
docker run \
 --name mongoclient \
 -p 3000:3000 \
 --link mongodb:mongodb \
 -d \
 mongoclient/mongoclient
  1. Run the application:
    npm run prod
  2. Run tests:
    npm test

API Endpoints 🛣️

The API endpoints can be view on swagger, starting the API and navigating to /documentation endpoint.

Testing ✅

The API is covered by automated tests that verify the correctness of each feature. Tests ensure that user authentication, data validation, and all CRUD operations are working as expected.

Run the tests using:

npm test

Contributions 🤝

Contributions are welcome! Feel free to fork the repository, create a new branch, and submit a pull request for review.

About

This API allows authenticated users to create, read, update, and delete heroes stored in MongoDB, with user authentication via PostgreSQL. Built with test coverage, it ensures data security and quality. The tech stack includes Node.js, Hapi, JWT, and Mocha.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published