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.
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).
To get started with the Online-Store-API, follow these steps:
- Clone the repository:
https://github.com/<your-username>/inventory-backend.git
- Install dependencies:
npm install
- 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',
};
- Run migrates:
npm run migrate
- Run seeds:
npm run seeds
- Start the server:
npm run dev
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 |