Skip to content

bohdan-mykhailenko/api_inventory-app

Repository files navigation

Inventory API

Overview

Description

This repository contains the source code for the Inventory-API project, which serves as the backend for the inventory application. The API is based on Node.js, Express.js and Socket.io, and it interacts with a PostgreSQL database using the Sequelize ORM.

Features

The API provides the following features:

  • Get data: Get orders and products with certain criteria.
  • Post data: Create a new order or product.
  • Delete data: Delete any required order or product.
  • Count active sessions: Using the web-socket server the app count sessions.

Additional features:

  • Image upload: Store image files and use the static feature.
  • Filtering: Filtering products and orders by query or type(for products).

Technologies

Getting Started

To get started with the Online-Store-API, follow these steps:

  1. Clone the repository:
https://github.com/<your-username>/inventory-backend.git
  1. Install dependencies:
npm install
  1. Set up PostgreSQL Database:
  • Open the database/config.ts file and add your PostgreSQL database configuration.
export const config = {
  DB_HOST: 'host',
  DB_NAME: 'name',
  DB_USERNAME: 'username',
  DB_PASSWORD: 'password',
};
  1. Run migrates:
npm run migrate
  1. Run seeds:
npm run seeds
  1. Start the server:
npm run dev

Endpoints

The base URL for the API is: https://inventory-backend-production-324c.up.railway.app

Method Endpoint Description Body
Products
GET /products/:productId Get product with certain id. NULL
GET /products?query=query&type=type Get all products with filtering by query and type NULL
GET /products/order/orderId Get all products for certain order. NULL
POST /products Create new product with all required fields connected to existed order.
{
 serialNumber: string,
 isNew: boolean,
 isRepairing: boolean,
 photo: Blob,
 title: string,
 type: string,
 specification: string,
 guarantee: JSON.Stringify({
   start: string,
   end: string,
 }),
 price: JSON.Stringify({
   value: number,
   symbol: string,
   isDefault: number,
  },
  {
   value: number,
   symbol: string,
   isDefault: number,
 });
 date: string,
}
        
DELETE /products/:productId Delete product with certain id. NULL
Orders
GET /orders/:orderId Get orderwith certain id. NULL
GET /orders?query=query Get all orders filtering by query. NULL
POST /orders Create new order with all required fields.
{
 title: string,
 date: string,
 description: string,
}
       
DELETE /orders/:orderId Delete order with certain id and all connected products. NULL