CartButler API is a Node.js application that provides various endpoints for managing categories, products, customers, and more. It uses Express.js for the server and Prisma for database interactions.
Api link
https://southern-shard-449119-d4.nn.r.appspot.com/-
Clone the repository:
git clone https://github.com/yourusername/CartButler.git cd CartButler -
Install the dependencies:
npm install
-
Run the Prisma migrations:
npx prisma migrate dev
-
Start the server:
node index.js
-
The server will be running at http://localhost:5000.
-
GET /
Returns a welcome message.
curl http://localhost:5000/
-
GET /categories
Returns a list of all categories.
curl http://localhost:5000/categories?language_id=en-US
-
GET /suggestions
Returns product suggestions based on a query parameter.
curl http://localhost:5000/suggestions?query=example
-
GET /search
Searches for products based on a query or categoryID parameter. At least one of the parameters is required. The endpoint returns products based on the provided parameters, limited to 10 results, and sorted by creation date.
curl http://localhost:5000/search?query=example&category_id=1&language_id=en-US
-
GET /product
Returns product details by ID.
curl http://localhost:5000/product?id=1&language_id=en-US
-
POST /cart
Adds an item to the shopping cart or updates the quantity if the item already exists. If the quantity is set to 0, the item is removed from the cart.
curl -X POST http://localhost:5000/cart -H "Content-Type: application/json" -d '{"user_id": "1", "product_id": "1", "quantity": 2}'
-
GET /cart
Retrieves the shopping cart items for a user.
curl http://localhost:5000/cart?user_id=<USER_ID>
-
GET /shopping-results
Calculates and returns the smallest shopping list price sorted by store price. The endpoint accepts a list of products with their quantities in the request body.
curl -X GET http://localhost:5000/shopping-results?cart_id=<CART_ID>&user_id=<USER_ID>
The following environment variables need to be set in the .env file:
DATABASE_URL: The connection string for the database.GCLOUD_STORAGE_BUCKET: The name of your Google Cloud Storage bucket.