init from origin + update

This commit is contained in:
2023-08-01 13:14:02 +03:00
commit 321dc4c3c5
1109 changed files with 16019 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
const router = require('express').Router()
// The code in this folder is partially based on the code from this repo:
// https://bitbucket.org/online-mentor/auth-system/src/master/stubs/api/
const wait = (time = 100) => (req, res, next) => setTimeout(next, time)
const stubs = [
['cart', 'get', 'success'],
// ['search', 'get', 'success'],
['cart', 'post', 'success'],
]
for (let [func, method, mock] of stubs) {
router[method](`/${func}`, wait(), (req, res) => {
res.send(require(`./mocks/${func}_${method}/${mock}`))
})
}
router.get('/search', wait(), (req, res, _) => {
let data = require('./mocks/search_get/success.json')
let { items } = data
const filters = req.query.filters.length > 0 ? req.query.filters.split(',') : []
const query = req.query.query.toLowerCase()
const chairsToSend = []
for (const chair of items) {
if (chair.model.toLowerCase().includes(query) && filters.every((tag) => chair.tags.includes(tag))) {
chairsToSend.push(chair)
}
}
res.send(
{
success: true,
items: chairsToSend,
},
)
})
module.exports = router

View File

@@ -0,0 +1,4 @@
{
"success": true,
"items": []
}

View File

@@ -0,0 +1,4 @@
{
"success": false,
"message": "Error retrieving cart"
}

View File

@@ -0,0 +1,18 @@
{
"success": true,
"items": [
{
"id": "42",
"model": "model A",
"price_usual": "$299",
"picture": "https://cdn.shopify.com/s/files/1/0011/1273/5803/products/LF-HB_BrisaBlackOnyx_shadow_clip_c-j_800x.jpg?v=1612828182"
},
{
"id": "322",
"model": "model T",
"price_usual": "$499",
"price_discounted": "$69",
"picture": "https://ehire.co.za/wp-content/uploads/2018/10/furniture-chairs-conference-chair-charcoal.jpg"
}
]
}

View File

@@ -0,0 +1,4 @@
{
"success": false,
"message": "Unknown action: not_add_or_remove"
}

View File

@@ -0,0 +1,3 @@
{
"success": true
}

View File

@@ -0,0 +1,4 @@
{
"success": true,
"items": []
}

View File

@@ -0,0 +1,4 @@
{
"success": false,
"message": "Error retrieving search results"
}

View File

@@ -0,0 +1,21 @@
{
"success": true,
"items": [
{
"id": "101",
"model": "model M",
"price_usual": "$9",
"price_discounted": "$4.99",
"picture": "https://dg-home.ru/pic/234417/taburet_tronco_kollektsiia_tronko__4__big.jpg",
"tags": ["for_children", "ikea", "yellow", "spruce"]
},
{
"id": "1337",
"model": "model H",
"price_usual": "$1",
"price_discounted": "$0.01",
"picture": "https://media.istockphoto.com/photos/old-broken-chair-picture-id157336134",
"tags": ["for_children", "ikea", "multi_color", "spruce"]
}
]
}

View File

@@ -0,0 +1,13 @@
{
"success": true,
"items": [
{
"id": "1337",
"model": "model H",
"price_usual": "$1",
"price_discounted": "$0.01",
"picture": "https://media.istockphoto.com/photos/old-broken-chair-picture-id157336134",
"tags": ["for_children", "ikea", "multi_color", "spruce"]
}
]
}

View File

@@ -0,0 +1,13 @@
{
"success": true,
"items": [
{
"id": "1337",
"model": "model H",
"price_usual": "$1",
"price_discounted": "$0.01",
"picture": "https://media.istockphoto.com/photos/old-broken-chair-picture-id157336134",
"tags": ["for_children", "ikea", "multi_color", "spruce"]
}
]
}

View File

@@ -0,0 +1,67 @@
{
"success": true,
"items": [
{
"id": "322",
"model": "model T",
"price_usual": "$499",
"price_discounted": "$69",
"picture": "https://ehire.co.za/wp-content/uploads/2018/10/furniture-chairs-conference-chair-charcoal.jpg",
"tags": ["office", "chairman", "black", "dark_oak"]
},
{
"id": "42",
"model": "model A",
"price_usual": "$299",
"picture": "https://cdn.shopify.com/s/files/1/0011/1273/5803/products/LF-HB_BrisaBlackOnyx_shadow_clip_c-j_800x.jpg?v=1612828182",
"tags": ["office", "gamer", "argos", "black", "red", "maple"]
},
{
"id": "228",
"model": "model G",
"price_usual": "$999",
"price_discounted": "$599",
"picture": "https://www.powerplanetonline.com/cdnassets/silla_gaming_white_shark_monza_rojo_01_l.jpg",
"tags": ["gamer", "chairman", "red", "acacia"]
},
{
"id": "101",
"model": "model M",
"price_usual": "$9",
"price_discounted": "$4.99",
"picture": "https://dg-home.ru/pic/234417/taburet_tronco_kollektsiia_tronko__4__big.jpg",
"tags": ["for_children", "ikea", "yellow", "spruce"]
},
{
"id": "111",
"model": "model C",
"price_usual": "$199",
"picture": "https://www.techinn.com/f/13809/138093984/talius-caiman-gaming-chair.jpg",
"tags": ["gamer", "dx_racer", "black", "yellow", "oak"]
},
{
"id": "1337",
"model": "model H",
"price_usual": "$1",
"price_discounted": "$0.01",
"picture": "https://media.istockphoto.com/photos/old-broken-chair-picture-id157336134",
"tags": ["for_children", "ikea", "multi_color", "spruce"]
},
{
"id": "227",
"model": "model K",
"price_usual": "$549",
"price_discounted": "$499",
"picture": "https://l33t-gaming.com/wp-content/uploads/2021/01/160373_01.png",
"tags": ["gamer", "office", "chairman", "black", "white", "birch"]
},
{
"id": "121",
"model": "model Q",
"price_usual": "$949",
"price_discounted": "$899",
"picture": "https://target.scene7.com/is/image/Target/GUEST_1144a161-ee20-484b-b9a1-724bbee36c41?wid=488&hei=488&fmt=pjpeg",
"tags": ["gamer", "secretlab", "multi_color", "spruce"]
}
]
}