Giter Site home page Giter Site logo

backend-marketplace's Introduction

Marketplace API

Setup

  1. Clone the repository

    git clone 
    cd backend-gesa
  2. Install dependencies

    npm install
  3. Configure environment variables

    • Create a .env file in the root directory

    • Add the following content

      JWT_SECRET=your_jwt_secret
      DATABASE = 'marketplace'
      DATABASE_USERNAME = 'username'
      DATABASE_PASSWORD = 'password'
      DATABASE_HOST = 'localhost'
      DATABASE_PORT = 3306
      DATABASE_TYPE = 'mysql'
      DATABASE_LOGGING = false
  4. Setup the database

    • Create a MySQL database named marketplace
    • Configure your database credentials in .env
  5. Start the server

    npm run start

Usage

Auth

Register

POST /api/auth/register Body: { "username": "merchant1", "password": "password", "role": "merchant" }

Login

POST /api/auth/login Body: { "username": "merchant1", "password": "password" }

Products

Create Product (Merchant only)

POST /api/products Headers: { "Authorization": "Bearer your_jwt_token" } Body: { "name": "Product A", "price": 20000 }

List Products

GET /api/products

Update Product (Merchant only)

PUT /api/products/:id Headers: { "Authorization": "Bearer your_jwt_token" } Body: { "name": "Product A Updated", "price": 25000 }

Delete Product (Merchant only)

DELETE /api/products/:id Headers: { "Authorization": "Bearer your_jwt_token" }

Transactions

Create Transaction (Customer only)

POST /api/transactions Headers: { "Authorization": "Bearer your_jwt_token" } Body: { "productId": 1, "quantity": 3 }

Get Transactions by Merchant (Merchant only)

GET /api/transactions/merchant Headers: { "Authorization": "Bearer your_jwt_token" }

Postman Collection

  • Import the provided postman_collection.json into Postman to quickly test the endpoints.

backend-marketplace's People

Contributors

gesarizky 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.