Simplified backend for e-commerce apps
🏠 Homepage
✨ Demo
- ROBUST ROUTES (Validation & Sanitizer)
- AUTHENTICATION & AUTHORIZATION
- JWT (Token & Refresh Token)
- HASH (Password with Argon2 Winner of PHC)
- ENCRYPTION (Some data)
- COOKIE (HTTP Only Cookie)
- HANDLER (Error & Form Data)
- STANDARIZE (Error & Code)
- CACHE (Redis)
- LINTER (Code)
- MANY MORE....
- JavaScript
- NodeJS
- ExpressJS
- PostgreSQL
- Redis
- Cloudinary
- Argon2
- argon2: An Argon2 library for Node
- cloudinary: Cloudinary NPM for node.js integration
- cookie-parser: Parse HTTP request cookies
- cors: Node.js CORS middleware
- cross-env: Run scripts that set and use environment variables across platforms
- dotenv: Loads environment variables from .env file
- duration-js: small simple library for dealing with durations
- express: Fast, unopinionated, minimalist web framework
- express-validator: Express middleware for the validator module.
- global: Require global variables
- helmet: help secure Express/Connect apps with various HTTP headers
- http-errors: Create HTTP error objects
- jsonwebtoken: JSON Web Token implementation (symmetric and asymmetric)
- morgan: HTTP request logger middleware for node.js
- multer: Middleware for handling
multipart/form-data. - nodemailer: Easy as cake e-mail sending from your Node.js applications
- nodemon: Simple monitor script for use during development of a Node.js app.
- pg: PostgreSQL client - pure javascript & libpq with the same API
- redis: A modern, high performance Redis client
- serve-favicon: favicon serving middleware with caching
- string-crypto: Small and simple (yet secure) library to encrypt and decrypt strings using PBKDF2 for key derivation and AES (defaulted to 256-bit / SHA512)
- xss-clean: middleware to sanitize user input
- eslint: An AST-based pattern checker for JavaScript.
- eslint-config-standard: JavaScript Standard Style - ESLint Shareable Config
- eslint-plugin-import: Import with sanity.
- eslint-plugin-n: Additional ESLint's rules for Node.js
- eslint-plugin-promise: Enforce best practices for JavaScript promises
| Environment | Value | Description |
|---|---|---|
| PORT | 5000 |
Port |
| PGHOST | localhost |
Database host |
| PGPORT | 8080 |
Database port |
| PGDATABASE | postgres |
Database name |
| PGUSER | postgres |
Database username |
| PGPASSWORD | - | Database password |
| FRONTEND_URL | your_frontend_url |
Frontend url without slash in the end for Cross Origin (CORS) |
| CLOUDINARY_URL | cloudinary:// |
Cloudinary URL |
| SMTP_HOST | - | SMTP host |
| SMTP_PORT | - | SMTP port |
| SMTP_USERNAME | - | SMTP username |
| SMTP_PASSWORD | - | SMTP password |
| REDIS_URL | rediss://default:password@host:port |
Redis url cluster for production |
| REDIS_CACHE_LIFE | 3m |
Redis cache expiration (3 minutes or more) |
| JWT_SECRET_KEY | - | JWT Secret Key |
| JWT_REFRESH_SECRET_KEY | - | JWT Secret Key (Refresh token) |
| JWT_TOKEN_LIFE | 4h |
JWT Life (4 hours or more) |
| JWT_REFRESH_TOKEN_LIFE | 1d |
JWT Life (Refresh token 1 day or more) |
| JWT_ALGORITHM | HS256 |
JWT Algorithm (see on wikipedia algorithm programming) |
| ENCRYPTION_PASSWORD | - | Encryption password (your password) |
| ENCRYPTION_SALT | - | Encryption salt (your salt) |
| ENCRYPTION_DIGEST | sha512 |
Encryption digest (see on wikipedia algorithm digest) |
| SITE_NAME | site_name |
Site name |
| MAX_FILE_SIZE | 5 |
File size number (5mb or more) |
| COOKIE_SECRET_KEY | - | Cookie secret key (random) |
| EMAIL_SERVICE | support@example.com |
Email service's (Customer Care) |
| Endpoint Development | Endpoint Production |
|---|---|
https://localhost:8080/api/v1 |
https://tokopaedi.up.railway.app/api/v1 |
POST /api/v1/auth/register| Parameter | Type | Description |
|---|---|---|
name |
string |
Required. Name of new user to insert |
email |
string |
Required. Email of new user to verification |
password |
string |
Required. Password of new user to sign in |
picture |
file |
Optional. Picture of new user |
role |
string |
Required. Role of new user to authorization |
GET /api/v1/auth/verification/:code| Parameter | Type | Description |
|---|---|---|
code |
string |
Required. Long text of code to verification |
POST /api/v1/auth/login| Parameter | Type | Description |
|---|---|---|
email |
string |
Required. Email of existing user to sign in |
password |
string |
Required. Password of existing user to sign in |
GET /api/v1/auth/refresh-token| Parameter | Type | Description |
|---|---|---|
- |
- |
- |
GET /api/v1/auth/logoutINCLUDE BEARER TOKEN!
| Parameter | Type | Description |
|---|---|---|
- |
- |
- |
GET /api/v1/usersINCLUDE BEARER TOKEN!
| Parameter | Type | Description |
|---|---|---|
search |
string |
Optional. Keyword to search users |
page |
integer |
Optional. Current page of users |
limit |
integer |
Optional. Limit data of users to show |
orderBy |
string |
Optional. Ordering data by key name |
sortBy |
string |
Optional. Sorting data by ASCENDING or DESCENDING (ASC / DESC) |
GET /api/v1/users/:idINCLUDE BEARER TOKEN!
| Parameter | Type | Description |
|---|---|---|
id |
integer |
Required. Id of user to fetch |
POST /api/v1/usersINCLUDE BEARER TOKEN!
| Parameter | Type | Description |
|---|---|---|
name |
string |
Required. Name of new user to insert |
email |
string |
Required. Email of new user to insert |
password |
string |
Required. Password of new user to insert |
picture |
file |
Optional. Picture of new user |
role |
string |
Required. Role of new user to insert |
PUT /api/v1/users/:idINCLUDE BEARER TOKEN!
| Parameter | Type | Description |
|---|---|---|
id |
integer |
Required. Id of user to update |
name |
string |
Optional. New name of existing user to update |
email |
string |
Optional. New email of existing user to update |
password |
string |
Optional. New password of existing user to update |
picture |
file |
Optional. New picture of existing user to update |
role |
string |
Optional. New role of existing user to update |
DELETE /api/v1/users/:idINCLUDE BEARER TOKEN!
| Parameter | Type | Description |
|---|---|---|
id |
integer |
Required. Id of user to delete |
GET /api/v1/categories| Parameter | Type | Description |
|---|---|---|
search |
string |
Optional. Keyword to search categories |
page |
integer |
Optional. Current page of categories |
limit |
integer |
Optional. Limit data of categories to show |
orderBy |
string |
Optional. Ordering data by key name |
sortBy |
string |
Optional. Sorting data by ASCENDING or DESCENDING (ASC / DESC) |
GET /api/v1/categories/:id| Parameter | Type | Description |
|---|---|---|
id |
integer |
Required. Id of category to fetch |
POST /api/v1/categoriesINCLUDE BEARER TOKEN!
| Parameter | Type | Description |
|---|---|---|
name |
string |
Required. Name of new category to insert |
PUT /api/v1/categories/:idINCLUDE BEARER TOKEN!
| Parameter | Type | Description |
|---|---|---|
id |
integer |
Required. Id of category to update |
name |
string |
Required. New name of existing category to update |
DELETE /api/v1/categories/:idINCLUDE BEARER TOKEN!
| Parameter | Type | Description |
|---|---|---|
id |
integer |
Required. Id of category to delete |
GET /api/v1/products| Parameter | Type | Description |
|---|---|---|
search |
string |
Optional. Keyword to search products |
page |
integer |
Optional. Current page of products |
limit |
integer |
Optional. Limit data of products to show |
orderBy |
string |
Optional. Ordering data by key name |
sortBy |
string |
Optional. Sorting data by ASCENDING or DESCENDING (ASC / DESC) |
GET /api/v1/products/:id| Parameter | Type | Description |
|---|---|---|
id |
integer |
Required. Id of product to fetch |
POST /api/v1/productsINCLUDE BEARER TOKEN!
| Parameter | Type | Description |
|---|---|---|
title |
string |
Required. Title of new product to insert |
description |
string |
Required. Description of new product to insert |
price |
integer |
Required. Price of new product to insert |
thumbnail |
file |
Optional. Thumbnail of new product |
seller_id |
integer |
Required. Seller ID of new product to constraint |
category_id |
integer |
Required. Category ID of new product to constraint |
PUT /api/v1/products/:idINCLUDE BEARER TOKEN!
| Parameter | Type | Description |
|---|---|---|
id |
integer |
Required. Id of product to update |
title |
string |
Optional. New title of existing product to update |
description |
string |
Optional. New description of existing product to update |
price |
integer |
Optional. New price of existing product to update |
thumbnail |
file |
Optional. New thumbnail of existing product to update |
seller_id |
integer |
Optional. New seller ID of existing product to constraint |
category_id |
integer |
Optional. New sategory ID of existing product to constraint |
DELETE /api/v1/products/:idINCLUDE BEARER TOKEN!
| Parameter | Type | Description |
|---|---|---|
id |
integer |
Required. Id of product to delete |
GET /api/v1/transactionsINCLUDE BEARER TOKEN!
| Parameter | Type | Description |
|---|---|---|
search |
string |
Optional. Keyword to search transactions |
page |
integer |
Optional. Current page of transactions |
limit |
integer |
Optional. Limit data of transactions to show |
orderBy |
string |
Optional. Ordering data by key name |
sortBy |
string |
Optional. Sorting data by ASCENDING or DESCENDING (ASC / DESC) |
GET /api/v1/transactions/:idINCLUDE BEARER TOKEN!
| Parameter | Type | Description |
|---|---|---|
id |
integer |
Required. Id of transaction to fetch |
POST /api/v1/transactionsINCLUDE BEARER TOKEN!
| Parameter | Type | Description |
|---|---|---|
buyer_id |
integer |
Required. Buyer ID of new transaction to constraint |
product_id |
integer |
Required. Product ID of new transaction to constraint |
quantity |
integer |
Required. Quantity of new transaction to insert |
price |
integer |
Required. Price of new transaction to insert |
status |
string |
Optional. Status of new transaction to insert (pending, success, failed) |
PUT /api/v1/transactions/:idINCLUDE BEARER TOKEN!
| Parameter | Type | Description |
|---|---|---|
id |
integer |
Required. Id of transaction to update |
buyer_id |
integer |
Optional. New buyer ID of existing transaction to constraint |
product_id |
integer |
Optional. New product ID of existing transaction to constraint |
quantity |
integer |
Optional. New quantity of existing transaction to update |
price |
integer |
Optional. New price of existing transaction to update |
status |
string |
Optional. New status of existing transaction to update (pending, success, failed) |
DELETE /api/v1/transactions/:idINCLUDE BEARER TOKEN!
| Parameter | Type | Description |
|---|---|---|
id |
integer |
Required. Id of transaction to delete |
This is a Node.js module available through the
npm registry. It can be installed using the
npm
or
yarn
command line tools.
Clone the project
git clone https://github.com/chlasswg26/tokopaedi-backendGo to the project directory
cd tokopaedi-backendRename environment files .env.example to .env and filled up the environment variables
mv .env.example .envInstall dependencies
yarn installStart the server
yarn dev- Our's mentor Zaki Maliki
- Best search engine's Google
- Most helped forum Stack Overflow
👤 Ichlas Wardy Gustama ichlaswardy26@gmail.com
- Website: https://chlasswg26.github.io/chlasswg26
- Github: @chlasswg26
- LinkedIn: @ichlas-wardy
Give a ⭐️ if this project helped you!
Copyright © 2022 Ichlas Wardy Gustama ichlaswardy26@gmail.com.
This project is MIT licensed.
