You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This sample demonstrates using Mongoose to build an eCommerce shopping cart using [Netlify Functions](https://www.netlify.com/products/functions/), which runs on [AWS Lambda](https://mongoosejs.com/docs/lambda.html).
4
+
5
+
Other tools include:
6
+
7
+
1. Stripe for payment processing
8
+
2.[Mocha](https://masteringjs.io/mocha) and [Sinon](https://masteringjs.io/sinon) for testing
9
+
10
+
## Running This Example
11
+
12
+
1. Make sure you have a MongoDB instance running on `localhost:27017`, or update `mongodbUri` in `.config/development.js` to your MongoDB server's address.
13
+
2. Run `npm install`
14
+
3. Run `npm run seed`
15
+
4. Run `npm start`
16
+
5. Visit `http://localhost:8888/.netlify/functions/getProducts` to list all available products
17
+
6. Run other endpoints using curl or postman
18
+
19
+
## Testing
20
+
21
+
Make sure you have a MongoDB instance running on `localhost:27017`, or update `mongodbUri` in `.config/test.js` to your MongoDB server's address.
22
+
Then run `npm test`.
23
+
24
+
```
25
+
$ npm test
26
+
27
+
> test
28
+
> env NODE_ENV=test mocha ./test/*.test.js
29
+
30
+
Using test
31
+
32
+
33
+
Add to Cart
34
+
✔ Should create a cart and add a product to the cart
35
+
✔ Should find the cart and add to the cart
36
+
✔ Should find the cart and increase the quantity of the item(s) in the cart
37
+
38
+
Checkout
39
+
✔ Should do a successful checkout run
40
+
41
+
Get the cart given an id
42
+
✔ Should create a cart and then find the cart.
43
+
44
+
Products
45
+
✔ Should get all products.
46
+
47
+
Remove From Cart
48
+
✔ Should create a cart and then it should remove the entire item from it.
49
+
✔ Should create a cart and then it should reduce the quantity of an item from it.
0 commit comments