chore: 🤖 update env variables

This commit is contained in:
Bolaji 2022-05-13 07:48:16 +01:00
parent f11ff29e3b
commit 9e68d2efbd
No known key found for this signature in database
GPG Key ID: 00342E72694643BB
6 changed files with 5287 additions and 5392 deletions

View File

@ -1,6 +1,6 @@
import type { CheckoutEndpoint } from '.' import type { CheckoutEndpoint } from '.'
import getCredentials from '../../utils/getCredentials' import getCredentials from '../../utils/getCredentials'
import { Order } from '@commercelayer/js-sdk' import Order from '@commercelayer/sdk'
const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({ const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({
req, req,
@ -16,9 +16,9 @@ const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({
if (val.indexOf(name) === 0) accessToken = val.substring(name.length) if (val.indexOf(name) === 0) accessToken = val.substring(name.length)
}) })
const { endpoint } = getCredentials() const { ENDPOINT } = getCredentials()
if (orderId && accessToken) { if (orderId && accessToken) {
const clOrder = await Order.withCredentials({ endpoint, accessToken }) const clOrder = await Order.withCredentials({ ENDPOINT, accessToken })
.includes('lineItems') .includes('lineItems')
.find(orderId as string, { rawResponse: true }) .find(orderId as string, { rawResponse: true })
const checkoutUrl = clOrder.data.attributes.checkout_url const checkoutUrl = clOrder.data.attributes.checkout_url

View File

@ -1,9 +1,9 @@
import { Product } from '@vercel/commerce/types/Product' import { Product } from '@vercel/commerce/types/Product'
import { CONTENT_DATA_URL } from '../../const'
export type Products = (Product & { categoryId: string; brandId: string })[] export type Products = (Product & { categoryId: string; brandId: string })[]
export default async function getContentData(id?: string): Promise<Products> { export default async function getContentData(id?: string): Promise<Products> {
const url = process.env.NEXT_PUBLIC_COMMERCELAYER_CONTENT_DATA_URL as string const products = (await (await fetch(CONTENT_DATA_URL)).json()).products as Products
const products = (await (await fetch(url)).json()).products as Products
return !id ? products : products.filter((p) => p.id === id) return !id ? products : products.filter((p) => p.id === id)
} }

View File

@ -1,9 +1,9 @@
import { getCookie } from './cookies' import { getCookie } from './cookies'
import { ENDPOINT } from '../../const'
export default function getCredentials() { export default function getCredentials() {
const endpoint = process.env.NEXT_PUBLIC_COMMERCELAYER_ENDPOINT as string
const accessToken = getCookie('CL_TOKEN') as string const accessToken = getCookie('CL_TOKEN') as string
return { accessToken, endpoint } return { accessToken, ENDPOINT }
} }
type ReturnObj = { type ReturnObj = {

View File

@ -1,3 +1,4 @@
export const ENDPOINT = process.env.NEXT_PUBLIC_COMMERCELAYER_ENDPOINT as string; export const ENDPOINT = process.env.NEXT_PUBLIC_COMMERCELAYER_ENDPOINT as string;
export const CLIENTID = process.env.NEXT_PUBLIC_COMMERCELAYER_CLIENT_ID as string; export const CLIENTID = process.env.NEXT_PUBLIC_COMMERCELAYER_CLIENT_ID as string;
export const SCOPE = process.env.NEXT_PUBLIC_COMMERCELAYER_MARKET_SCOPE as string; export const SCOPE = process.env.NEXT_PUBLIC_COMMERCELAYER_MARKET_SCOPE as string;
export const CONTENT_DATA_URL = process.env.NEXT_PUBLIC_COMMERCELAYER_CONTENT_DATA_URL as string;

View File

@ -50,4 +50,5 @@ NEXT_PUBLIC_COMMERCEJS_DEPLOYMENT_URL=
NEXT_PUBLIC_COMMERCELAYER_CLIENT_ID= NEXT_PUBLIC_COMMERCELAYER_CLIENT_ID=
NEXT_PUBLIC_COMMERCELAYER_ENDPOINT= NEXT_PUBLIC_COMMERCELAYER_ENDPOINT=
NEXT_PUBLIC_COMMERCELAYER_MARKET_SCOPE= NEXT_PUBLIC_COMMERCELAYER_MARKET_SCOPE=
NEXT_PUBLIC_COMMERCELAYER_CONTENT_DATA_URL=

10659
yarn.lock

File diff suppressed because it is too large Load Diff