Changed the way ops are created

This commit is contained in:
Luis Alvarez
2021-05-14 14:52:14 -05:00
parent f0413fa0a4
commit 591cd6d4e6
4 changed files with 38 additions and 28 deletions

View File

@@ -1,12 +1,12 @@
import type { GetAPISchema } from '@commerce/api'
import type { CartSchema } from '../../types/cart'
import type { CommerceAPI } from '..'
import type { BigcommerceAPI } from '..'
import getCart from './get-cart'
import addItem from './add-item'
import updateItem from './update-item'
import removeItem from './remove-item'
export type CartAPI = GetAPISchema<CommerceAPI, CartSchema>
export type CartAPI = GetAPISchema<BigcommerceAPI, CartSchema>
export type CartEndpoint = CartAPI['endpoint']

View File

@@ -1,6 +1,7 @@
import type { NextApiHandler } from 'next'
import type { RequestInit } from '@vercel/fetch'
import {
CommerceAPI,
CommerceAPIConfig,
getCommerceApi as commerceApi,
getEndpoint,
@@ -112,9 +113,11 @@ export type Provider = typeof provider
export type APIs = CartAPI
export type BigcommerceAPI<P extends Provider = Provider> = CommerceAPI<P>
export function getCommerceApi<P extends Provider>(
customProvider: P = provider as any
) {
): BigcommerceAPI<P> {
const api = commerceApi(customProvider)
return Object.assign(api, {