Code Monkey home page Code Monkey logo

store-api's Introduction

Store API

Table of Contents

Overview

Welcome to the Store-api! This project is a comprehensive Node.js application built to manage various aspects of a hypothetical system, offering functionalities for user management, product handling, order processing, and financial transactions. The API leverages the Express.js framework for robust route handling and Prisma ORM for seamless interaction with the database.

Technologies Used

  • Node.js: A JavaScript runtime for server-side development.

  • Express.js: A web application framework for Node.js, simplifying route handling and middleware integration.

  • Prisma ORM: An open-source database toolkit for TypeScript and Node.js that simplifies database interactions.

  • Swagger: API documentation tool for clear and accessible API exploration.

  • Multer: A middleware for handling multipart/form-data, useful for file uploads.

  • Cron: A time-based job scheduler for running periodic tasks.

Features

  • User Management: Create and authenticate users, manage user roles, and retrieve user information.

  • Product Operations: Handle products, categories, and their associations, enabling efficient product management.

  • Client and Wallet Management: Create and manage clients, their wallets, and credit transactions.

  • Order Processing: Facilitate the creation, retrieval, and modification of orders, associating them with clients and products.

  • Financial Transactions: Track and manage financial transactions, providing insights into credit changes and financial activities.

Installation

# Clone the repository
git clone https://github.com/Enrickyb/store-api.git

# Navigate to the project directory
cd store-api

# Install dependencies
npm install

Folder Structure

- /src
  - /controllers
  - /middlewares
  - /providers
  - /routes
- /uploads
- /docs
- /tests

Routes

Users

Create User

POST /api/users/create

Creates a new user.

Request
  • Headers:
    • Content-Type: application/json
Body
{
  "username": "example",
  "password": "examplepassword"
}
Response
  • Status: 201 Created
  • Body:
{
  "message": "User created successfully"
}

User Login

POST /api/users/login

Logs in a user.

Request
  • Headers:
    • Content-Type: application/json
Body
{
  "username": "example",
  "password": "examplepassword"
}
Response
  • Status: 200 OK
  • Body:
{
  "token": "your-auth-token"
}

Get Users by Client ID

GET /api/users/client/:client_id

Gets all users of a specific client.

Request
  • Headers:
    • Authorization: Bearer your-auth-token
Response
  • Status: 200 OK
  • Body:
[
  {
    "id": 1,
    "username": "user1"
  },
  {
    "id": 2,
    "username": "user2"
  }
  // ...
]

Products

Create Product

POST /api/products/create

Creates a new product.

Request
  • Headers:
    • Authorization: Bearer your-auth-token
    • Content-Type: multipart/form-data
Body
  • Form Data:
    • file: Product file
    • thumbnail: Product thumbnail
    • name: Product name
    • price: Product price
    • category_id: Category ID
Response
  • Status: 201 Created
  • Body:
{
  "message": "Product created successfully"
}

Get All Products

GET /api/products/all

Gets all products.

Request
  • Headers:
    • Authorization: Bearer your-auth-token
Response
  • Status: 200 OK
  • Body:
[
  {
    "id": 1,
    "name": "Product1",
    "price": 20.00,
    "categoryId": 1
  },
  {
    "id": 2,
    "name": "Product2",
    "price": 30.00,
    "categoryId": 2
  }
  // ...
]

Controllers

Provide information about the purpose and functionality of each controller in your project.

  • UserController: Manages user-related logic.
  • ProductController: Handles product-related operations.

Middleware

Explain the purpose of each middleware and when it is used.

  • authMiddleware: Validates user authentication.
  • serverAdminMiddleware: Ensures the user has server admin privileges.

Models

List and describe the models used in your project. Include details about each model's fields and relationships.

  • User: Represents a user with fields like username and password.
  • Product: Represents a product with fields like name and price.

Documentation

Em desenvolvimento

Testing

# Run tests
npm test

store-api's People

Contributors

enrickyb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.