mirror of
https://github.com/vercel/commerce.git
synced 2025-07-03 11:41:21 +00:00
* remove unused imports and localhost added as a local domain * Logo, Favicon and copyrights changed * Logo, Favicon and copyrights changed * Product Details page
25 lines
751 B
TypeScript
25 lines
751 B
TypeScript
import data from '../../data.json'
|
|
import { gateway as MoltinGateway } from '@moltin/sdk'
|
|
import normalizeProduct from '../../utils/normalize'
|
|
|
|
const Moltin = MoltinGateway({
|
|
client_id: process.env.NEXT_PUBLIC_ELASTICPATH_CLIENTID
|
|
})
|
|
|
|
export type GetAllProductPathsResult = {
|
|
products: Array<{ path: string }>
|
|
}
|
|
|
|
export default function getAllProductPathsOperation() {
|
|
async function getAllProductPaths(): Promise<GetAllProductPathsResult> {
|
|
let products = await Moltin.Products.Limit(200).All();
|
|
let normalizeProducts = await normalizeProduct(products.data)
|
|
let productPaths = normalizeProducts.map(({ path }) => ({ path }));
|
|
return await Promise.resolve({
|
|
products: productPaths
|
|
})
|
|
}
|
|
|
|
return getAllProductPaths
|
|
}
|