Haru API

Welcome to the Haru-Fashion API, a RESTful API for Haru-Fashion e-commerce web application.

This API can be used to access Haru-Fashion API endpoints, which can get information on various products, categories in our database. Certain information and actions, for example, retrieving customers, creating products, can only be done when authenticated and authorized.

This API is developed with NodeJS, Express, TypeScript, Prisma and PostgreSQL.

Admins 9

Description

Login as an admin.

Body
{ "email": "dummyadmin@gmail.com", "password": "verysecurepassword" }
Description

Update current logged-in admin’s password. User must type current password correctly in order to perform this action.

Body
{ "currentPassword": "verysecurepassword", "newPassword": "nextsecurepassword" }
Description

Add a new admin to the database. To perform this action, user must be authenticated and authorized as a superadmin.

Body
{ "username": "admin2", "email": "admin2@gmail.com", "password": "admin2", "role": "ADMIN" }
Description

Retrieve all admins from the database. This action can only be performed by superadmin role.

Description

Retrieve current logged-in admin’s details.

Description

Retrieve specific admin by their ID from the database. This action can only be performed by superadmin role.

Description

Seed data to the database when deployed. To perform this action, seeding password must be correct.

Body
{ "password": "seedingpasswordforapi" }
Description

Update specific admin by their ID. This action can only be performed by superadmin role.

Body
{ "username": "admin11", "active": true, "password": "admin11" }
Description

Update current logged-in admin’s details.

Body
{ "username": "updated admin", "email": "updatedemail@gmail.com" }

Auth 7

Description

Forgot password can be reset by providing email in the body. Reset password token is sent via email.

Body
{ "email": "demo@gmail.com" }
Description

Retrieve current logged-in customer’s details.

Description

Login as a customer when the customer is already registered.

Body
{ "email": "demo@gmail.com", "password": "demopassword" }
Description

Register a new customer by passing required fields in the body.

Body
{ "email": "demo@gmail.com", "fullname": "newuser", "password": "demopassword", "shippingAddress": "yangon", "phone": "09283928" }
Description

To reset password, this route can be requested (which is sent via email)

Body
{ "password": "newpassword" }
Description

Update current logged-in customer’s details.

Body
{ "fullname": "Mrs.Demo", "phone": "571661" }
Description

Update current logged-in customer’s password. Customer must type current password correctly in order to perform this action.

Body
{ "currentPassword": "demopassword2", "newPassword": "demopassword" }

Categories 5

Description

Add new category to the database. To perform this action, user must be authenticated and authorized.

Body
{ "name": "sneakers", "description": "this is desc", "thumbnailImage": "http://dummyimage.com/720x400.png/deefdd/000eee" }
Description

Remove a category by its ID from the database. To perform this action, user must be authenticated and authorized.

Description

Fetch all categories from the database. Includes select and ordering.

Query
KeyValueDescription
selectname,description
order_bycreatedAt.desc,name
Description

Fetch specific category by ID from the database. Includes select and ordering.

Description

Update specific category by its ID from the database. To perform this action, user must be authenticated and authorized.

Body
{ "name": "men" }

Customers 3

Description

Delete a customer by their ID from the database. To perform this action, user must be authenticated and authorized.

Description

Fetch all customers from the database. To perform this action, user must be authenticated and authorized.

Description

Fetch specific customer by their ID from the database. To perform this action, user must be authenticated and authorized.

Products 6

Description

Add new product to the database. To perform this action, user must be authenticated and authorized.

Body
{ "name": "Wallie", "price": "1500", "description": "this is just a description", "image1": "image1.png", "image2": "image2.png", "categoryId": "1" }
Description

Remove a product by its ID from the database. To perform this action, user must be authenticated and authorized.

Description

Fetch all products from the database. Includes select and ordering.

Query
KeyValueDescription
order_byprice.desc,name
skip50
limit10
pricegte:50
pricelt:100
stockgt:50
stocklt:70
selectname,price,stock
Description

Fetch specific product by ID from the database. Includes select and ordering.

Query
KeyValueDescription
includecategory
Description

Perform full-text search for all products.

Query
KeyValueDescription
qcondimentum
Description

Update specific product by its ID from the database. To perform this action, user must be authenticated and authorized.

Body
{ "name": "updated category", "price": "100", "discountPercent": "5", "description": "this is updated description", "detail": "this is updated detail", "categoryId": "2", "image1": "image1.png", "image2": "image2.png", "stock": "20" }