Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bohdan-mykhailenko/api_inventory-app

An API for the inventory app with database and files storage.
https://github.com/bohdan-mykhailenko/api_inventory-app

express nodejs postgresql sequelize socket-io

Last synced: 7 days ago
JSON representation

An API for the inventory app with database and files storage.

Awesome Lists containing this project

README

        

# Inventory API

## Overview
* [**Demo Link**](https://bohdan-mykhailenko.github.io/inventory/)
* [**Frontend Repo**](https://github.com/bohdan-mykhailenko/inventory)

## 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

- [TypeScript](https://www.typescriptlang.org/)
- [Node.js](https://nodejs.org/en)
- [Express](https://expressjs.com/)
- [Socket.io](https://socket.io/)
- [Sequelize](https://sequelize.org/)
- [Sequelize CLI](https://sequelize.org/docs/v7/cli/)
- [PostgreSQL](https://www.postgresql.org/)
- [Multer](https://github.com/expressjs/multer)

## Getting Started

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

1. Clone the repository:

```shell
https://github.com//inventory-backend.git
```

2. Install dependencies:

```shell
npm install
```

3. 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',
};
```

4. Run migrates:

```shell
npm run migrate
```

5. Run seeds:

```shell
npm run seeds
```

6. Start the server:

```shell
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