Giter VIP home page Giter VIP logo

rest-products-api's Introduction

REST Products API /w JWT Auth

REST api implementation created in express. Product resource routes are protected by a JWT authorization requirement. The JWT is implemented with a "refresh token" to allow the user to get a new access token without forcing a login every time the access token expires.

Appendix

File postman_collection.json includes whole required configuration to test app manually with Postman.

Tech stack:

Applicaiton framework

express: 4.18.2

Typing:

typescript: 4.9.4

Password hashing

bcrypt: 5.1.0

Authorization

jsonwebtoken: 8.5.1

Database and validation

mongoose: 6.8.0 zod: 3.19.1

Logging

pino: 8.7.0 pino-http: 8.2.1

Configuration

config: 3.3.8 dotenv: 16.0.3

Deployment

flyctl

API Reference

Users

Create a user / register

  POST /api/users
Request body Type Description
username string Required. User's username
password string Required. User's password
passwordConfirmation string Required. User's password again
email string Required. User's email

Get all users

  GET /api/users

Sessions

Create a session / sing in

  POST /api/sessions
Request body Type Description
username string Required. User's username
password string Required. User's password

Get all valid (signed in) sessions of current user

  GET /api/sessions

Invalidate current session, logout

  DELETE /api/sessions

Products

Get all products

  GET /api/products

Get specific product

  GET /api/products/${id}
Parameter Type Description
id string Required. Product's identifier

Create a product

  POST /api/products
Request body Type Description
name string Required. Product's name
quantity number Required. Product's quantity
price number Required. Price of 1 product
decription string Required. Minimum length: 120chars Product description
image string Required. URI to image of product

Update a product

  POST /api/products/${id}
Parameter Type Description
id string Required. Product's identifier
Request body Type Description
any product field from create product request any Optional.

Remove specific product

  DELETE /api/products/${id}
Parameter Type Description
id string Required. Product's identifier

Installation

Clone repository with git and then install it with yarn or npm:

  git clone https://github.com/kchn9/rest-users-products-api
  cd rest-users-products-api
  yarn install

License

MIT

Authors

rest-products-api's People

Contributors

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