A REST API for consumer-to-consumer sales using Express.js.
The REST API is currently in beta.
To get started with the REST API, follow these steps:
- Clone the repository:
git clone https://github.com/stsp93/emarket-rest-api.git
- Install the dependencies:
npm install
- Start the API:
npm start
The REST API requires a MongoDB database to be running.
The API will be available at http://localhost:3030
. You can test the endpoints using tools such as curl
or a REST client.
POST : /users/register
- Creates a user
- payload: (
email
(Unique and valid),username
(Unique and 3 chars at least),password
(3 chars at least))
POST : /users/login
- User logs in, returns JWT(username, email, _id)
POST : /users/logout
- User logout, blacklisting JWT
POST : /users/profile
- Returns profile data
GET : /users/replies
- Returns array of user replies
POST : /users/reply
- Post a message to spec user
- payload (
username
,reply
)
DELETE : /users/replies/:id
- Deletes reply with spec id
GET : /items/categories
- Returns an object of available categories and relevant image Urls.
Example
{ category1: category1ImageUrl, category2: category2ImageUrl}
GET : /items/:id
- Returns a specific item by its ID in form of an Object.
POST : /items
- Creates item (for logged in Users), returns the created object
- payload: (
title
(3 chars at least),category
(valid),imageUrl
(Optional),description
,location
,phone
(Optional),price
)
PUT : /items/:id
- Updates item (for logged in Users) and returns the edited object
PUT : /items/:id
- Delete item (for logged in Users) returns no content
cat
: Category query.q
: Item title query with case-insensitive Regexp.