Ecommerce store where an admin can set a coupon to automatically distribute to a customer every x transactions. On login, a customer should see if they have any discounts available and their relevant codes. Customers can use the discount code to purchase items. The admin should be able to view the total count of purchases made in the store and the overall count of discounts given out.
- Authentication & Authorization
- Use example token for checkout functionality
- As login functionality is out of scope refer to listed resolvers for expected on login functionality
getOwnCoupons()
getStoreOverview()
- Persisting Data
- Input Validation
- Automated Testing
- Payment processing functionality not required
Note: npm start will fail due to unloaded environment variables. Please use local command to load .env resources.
npm run local
Open localhost link to launch Apollo Studio.
- Install required dependencies
Note: NVM is not required, but is recommended in order keep dependencies working as expected
nvm use
npm install
- Use
.env.example
file to create your own.env
file with relevant credentials
Prerequisites:
- MySQL is installed
- MySQL server is running
Instructions:
- Run SQL query to initialize the punchcard database.
CREATE DATABASE IF NOT EXISTS punchcard;
- Run migrations to initialize and seed the punchcard database.
npm run migrate:run:local
Note: When you initialize the server, if you open the relevant port, it will open Apollo Studio. This will give you access to all available queries and mutations as well as the documentation. Example inputs have been provided below.
Example Token for Customer1:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwidXNlcklkIjoyLCJlbWFpbCI6ImN1c3RvbWVyMUBleGFtcGxlLmNvbSJ9.7fmPqv0naJ5zz4Tm6ezASDU1X6EBh1Axjj8sJBYZKzg
Note: Set Authorization handler with provided example token
{
"input": {
"couponCodes": "ABCDE",
"items": [
{
"id": "2",
"quantity": 3
}
]
}
}
{
"input": {
"couponCode": "LOYAL10",
"purchasesRequired": 5,
"dollarAmount": 10
}
}
{
"input": {
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"name": "USB-C Charging Cable",
"price": 5.99,
"stockQuantity": 20
}
}
{
"productId": "1"
}
{
"input": {
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore.",
"id": "1",
"stockQuantity": 22
}
}