Git Product home page Git Product logo

point-of-sales-api's Introduction

Point of Sales API

RESTful API for Point of Sales App


Table of contents

TODO Tasks

  • CRUD Products
  • CRUD Categories
  • Unique name (on categories and product) and email (on users)
  • Add/Reduce Products (Quantity)
  • Validation schema
  • Search product by name
  • Sort product by name, category, date updated
  • Pagination products
  • Upload image (on products)
  • Cannot reduce stock (on products) below 0
  • Allowed CORS
  • Authentication with JWT
  • Rows caching with redis

Stacks

  • NodeJS
  • MySQL
  • ExpressJS
  • Sequelize ORM
  • JWT
  • Joi Validator
  • Redis

Build Setup

  1. Clone repository $ git clone https://github.com/sutanlab/point-of-sales-api.git

  2. Install depedencies

# with npm
$ npm install

# or with yarn
$ yarn install
  1. Setup your environment variable in .env files (if not exists, create your own).
# NODE_ENV development | production | test
NODE_ENV = development

# DATABASE
DB_HOSTNAME = 127.0.0.1
DB_USERNAME = root
DB_PASSWORD = xxxx
DB_NAME = dbtest

# SECRET KEY
SECRET_JWT = xxxx
  1. Run database migrations (with shortcut scripts with yarn or npm run)
$ yarn db:init # create database

$ yarn db:migrate # run database migrations

$ yarn db:seed # run database seeder (if you want)

$ yarn db:rollback # rollback migrations

$ yarn db:drop # drop table
  1. Start API server
$ yarn watch # start and watch server

$ yarn start # start server

API Docs

Products

Method Endpoint Description Request Param Request Body Request Query
GET /api/product Get products - - search: STRING, limit: NUMBER, page: NUMBER, sort: STRING (column with order splitted by '-'. Ex: sort=name-asc (order by name ASC)
POST /api/product Create new product - name: STRING, category: STRING (UUID), description: STRING, price: NUMBER, stock: NUMBER, image: FILE -
GET /api/product/:id Get one product by id id: STRING (UUID) - -
PUT /api/product/:id Update product id: STRING (UUID) name: STRING, category: STRING (UUID), description: STRING, price: NUMBER, stock: NUMBER, image: FILE -
DELETE /api/product/:id Delete product id: STRING (UUID) - -
PATCH /api/product/stock/:id Add or reduce product id: STRING (UUID) operator: STRING (add/reduce), value: NUMBER -
GET /files/image/product/:image Get product image image: STRING (IMAGE NAME) - -

Category

Method Endpoint Description Request Param Request Body Request Query
GET /api/category Get category - - -
POST /api/category Create new category - name: STRING -
GET /api/category/:id Get one category by id id: STRING (UUID) - -
PUT /api/category/:id Update category id: STRING (UUID) name: STRING -
DELETE /api/category/:id Delete category id: STRING (UUID) - -

User

Method Endpoint Description Request Param Request Body Request Query
PUT /api/user/:id Update user id: STRING (UUID) name: STRING, email: STRING, password: STRING -
DELETE /api/user/:id Delete user id: STRING (UUID) - -

Auth

Method Endpoint Description Request Headers Request Body
POST /auth/register Register user - name: STRING, email: STRING, password: STRING
POST /auth/login Login user - email: STRING, password: STRING
GET /auth/info Get user info authorization: STRING (TOKEN) -

Copyright © 2019 by Sutan Gading Fadhillah Nasution

point-of-sales-api's People

Contributors

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