mirror of
https://github.com/vercel/commerce.git
synced 2025-07-25 11:11:24 +00:00
Changed the way ops are created
This commit is contained in:
@@ -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']
|
||||
|
||||
|
@@ -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, {
|
||||
|
Reference in New Issue
Block a user