-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from GSG-G10/46-cart-routers
cart router
- Loading branch information
Showing
9 changed files
with
38 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
const { getCart } = require('./pages'); | ||
const productDetails = require('./productDetails'); | ||
const { login, logout } = require('./auth'); | ||
|
||
module.exports = { | ||
login, | ||
logout, | ||
getCart, | ||
productDetails, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const { getItems } = require('../../database/queries/cart'); | ||
|
||
const getCart = async (req, res, next) => { | ||
try { | ||
const { id } = req.userObj; | ||
const items = await getItems(id); | ||
res.json(items); | ||
} catch (err) { | ||
next(err); | ||
} | ||
}; | ||
module.exports = getCart; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const getCart = require('./cart'); | ||
|
||
module.exports = { getCart }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ const buildDB = () => { | |
return connection.query(sql); | ||
}; | ||
|
||
|
||
buildDB(); | ||
|
||
module.exports = buildDB; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
const connection = require('../../connection'); | ||
|
||
module.exports = (productId, cartId) => connection.query('SELECT products.*, cart_items.quentity FROM products INNER JOIN cart_items ON cart_items.product_id=products.id INNER JOIN users ON cart_items.user_id = users.id WHERE cart_items.user_id = 3;', [productId, cartId]).then((data) => data.rows); | ||
module.exports = (userId) => connection | ||
.query( | ||
'SELECT products.*, cart_items.quentity FROM products INNER JOIN cart_items ON cart_items.product_id=products.id INNER JOIN users ON cart_items.user_id = users.id WHERE cart_items.user_id = $1;', | ||
[userId], | ||
) | ||
.then((data) => data.rows); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
const signupValidation = require('./signupValidation'); | ||
|
||
const authentication = require('./authentication'); | ||
|
||
module.exports = { | ||
signupValidation, | ||
authentication, | ||
}; | ||
module.exports = { authentication }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters