Expand variants

This commit is contained in:
Sebastian Rindom committed 2020-07-01 20:28:01 +02:00
1 parent 3e033bf646
commit 602cd2f914
3 files changed
+15 -10

No files matched your search

@@ -4,16 +4,19 @@ export default async (req, res) => {
const productService = req.scope.resolve("productService")
let product = await productService.retrieve(id)
product = await productService.decorate(product, [
product = await productService.decorate(
product,
[
"title",
"description",
"tags",
"handle",
"images",
"options",
"variants",
"published",
])
],
["variants"]
)
res.json({ product })
}
@@ -5,16 +5,19 @@ export default async (req, res) => {
products = await Promise.all(
products.map(
async product =>
await productService.decorate(product, [
await productService.decorate(
product,
[
"title",
"description",
"tags",
"handle",
"images",
"options",
"variants",
"published",
])
],
["variants"]
)
)
)
res.json({ products })
@@ -4,10 +4,10 @@ export default async (req, res) => {
const { id } = req.params
const schema = Validator.object().keys({
title: Validator.string().required(),
title: Validator.string(),
description: Validator.string().optional(),
tags: Validator.string().optional(),
handle: Validator.string().required(),
handle: Validator.string(),
images: Validator.array()
.items(Validator.string())
.optional(),
@@ -34,9 +34,8 @@ export default async (req, res) => {
"handle",
"images",
"options",
"variants",
"published",
])
], ["variants"])
res.json({ product: newProduct })
} catch (err) {
throw err