Skip to content

Simple REST API for a product management web app made using React, TypeScript and Express. For the DB PostgreSQL hosted in render and for the Testing Jest and Supertest

Notifications You must be signed in to change notification settings

Thomas465xd/rest_api-product-management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REST API Product Management

This is a REST API built for managing products, using a simple CRUD (Create, Read, Update, Delete) functionality. The API is developed with TypeScript, Node.js, and Express and is designed to handle requests for a product management application. It is deployed on Render’s free tier for both the web service and database.

Table of Contents

Overview

This API serves as the backend for a product management application, allowing users to create, view, update, and delete product records. It is designed to power a simple frontend interface for managing products.

Technologies Used

  • Node.js with TypeScript: For building the server and API logic.
  • Express: As the web application framework.
  • PostgreSQL: For database storage, with Sequelize as the ORM.
  • Jest and Supertest: For comprehensive testing, with 100% code coverage.
  • Render: For hosting the API and database on a free-tier environment.

Features

  • RESTful API Endpoints for full CRUD operations:
    • GET to retrieve all products or a product by ID.
    • POST to create a new product.
    • PUT to update an existing product’s information.
    • PATCH to modify a product’s availability.
    • DELETE to remove a product by ID.
  • Testing: Includes unit and integration tests for each endpoint, ensuring 100% code coverage with Jest and Supertest.
  • Error Handling: Comprehensive error handling to manage invalid requests and database errors.

Getting Started

Installation

  1. Clone the repository:
    git clone https://github.com/yourusername/rest_api-product-management.git
    cd rest_api-product-management
  2. Install Dependencies:
npm install

Environment Variables

Create a .env file in the root directory with the following variables:

DB_URL=your_database_url
FRONTEND_URL=https://your-frontend-app-url

Ensure DB_URL points to your PostgreSQL database on Render (or locally for development).

Running the API

  1. **Development Mode:
npm run dev
  1. **Production Mode:
npm run build
node dist/index.js

Testing

Run all tests with Jest and Supertest:

npm test

API Documentation

The API Documentation is made using swagger

Documentation URL

Deployment

The API is deployed on Render. To deploy this API:

    1. Link your repository to a Render web service.
    1. Add environment variables on Render corresponding to your .env file.
    1. Use Render’s PostgreSQL service for database hosting.

Made with ♥️ Thomas Schrödinger

About

Simple REST API for a product management web app made using React, TypeScript and Express. For the DB PostgreSQL hosted in render and for the Testing Jest and Supertest

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published