Move API to new Node architecture

Signed-off-by: Loan Laux <loan@outgrow.io>
This commit is contained in:
Loan Laux
2021-07-06 15:43:38 +03:00
parent 8dc6881cd9
commit 23e0d57cf5
32 changed files with 459 additions and 141 deletions

View File

@@ -0,0 +1,40 @@
import { ReactionCommerceConfig } from '../'
import { OperationContext } from '@commerce/api/operations'
import { Provider } from '@commerce'
export type Page = any
export type GetAllPagesResult<T extends { pages: any[] } = { pages: Page[] }> =
T
export default function getAllPagesOperation({
commerce,
}: OperationContext<Provider>) {
async function getAllPages(opts?: {
config?: Partial<ReactionCommerceConfig>
preview?: boolean
}): Promise<GetAllPagesResult>
async function getAllPages<T extends { pages: any[] }>(opts: {
url: string
config?: Partial<ReactionCommerceConfig>
preview?: boolean
}): Promise<GetAllPagesResult<T>>
async function getAllPages({
config: cfg,
preview,
}: {
url?: string
config?: Partial<ReactionCommerceConfig>
preview?: boolean
} = {}): Promise<GetAllPagesResult> {
const config = commerce.getConfig(cfg)
return {
pages: [],
}
}
return getAllPages
}