Skip to content

Commit

Permalink
Update to Next.js 13 (vercel#870)
Browse files Browse the repository at this point in the history
  • Loading branch information
cond0r authored Dec 21, 2022
1 parent 6d783ea commit 4efa502
Show file tree
Hide file tree
Showing 60 changed files with 889 additions and 454 deletions.
4 changes: 2 additions & 2 deletions packages/bigcommerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"uuidv4": "^6.2.13"
},
"peerDependencies": {
"next": "^12",
"next": "^13",
"react": "^18",
"react-dom": "^18"
},
Expand All @@ -73,7 +73,7 @@
"@types/node-fetch": "^2.6.2",
"@types/react": "^18.0.14",
"lint-staged": "^12.1.7",
"next": "^12.0.8",
"next": "^13.0.6",
"prettier": "^2.5.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({
config,
}) => {
const { cookies } = req
const cartId = cookies.get(config.cartCookie)
const customerToken = cookies.get(config.customerCookie)
const cartId = cookies.get(config.cartCookie)?.value
const customerToken = cookies.get(config.customerCookie)?.value

if (!cartId) {
return { redirectTo: '/cart' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type Customer = NonNullable<GetLoggedInCustomerQuery['customer']>

const getLoggedInCustomer: CustomerEndpoint['handlers']['getLoggedInCustomer'] =
async ({ req, config }) => {
const token = req.cookies.get(config.customerCookie)
const token = req.cookies.get(config.customerCookie)?.value

if (token) {
const { data } = await config.fetch<GetLoggedInCustomerQuery>(
Expand Down
4 changes: 2 additions & 2 deletions packages/commerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"zod": "^3.19.1"
},
"peerDependencies": {
"next": "^12",
"next": "^13",
"react": "^18",
"react-dom": "^18"
},
Expand All @@ -68,7 +68,7 @@
"@types/node-fetch": "2.6.2",
"@types/react": "^18.0.14",
"lint-staged": "^12.1.7",
"next": "^12.0.8",
"next": "^13.0.6",
"prettier": "^2.5.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/commerce/src/api/endpoints/cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const cartEndpoint: GetAPISchema<

let output
const { cookies } = req
const cartId = cookies.get(config.cartCookie)
const cartId = cookies.get(config.cartCookie)?.value

// Return current cart info
if (req.method === 'GET') {
Expand Down
2 changes: 1 addition & 1 deletion packages/commerce/src/api/endpoints/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const checkoutEndpoint: GetAPISchema<
})

const { cookies } = req
const cartId = cookies.get(config.cartCookie)!
const cartId = cookies.get(config.cartCookie)?.value
const input = await getInput(req)

// Get checkout
Expand Down
2 changes: 1 addition & 1 deletion packages/commerce/src/api/endpoints/customer/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const customerShippingEndpoint: GetAPISchema<
const { cookies } = req

// Cart id might be usefull for anonymous shopping
const cartId = cookies.get(config.cartCookie)
const cartId = cookies.get(config.cartCookie)?.value

// Return customer addresses
if (req.method === 'GET') {
Expand Down
2 changes: 1 addition & 1 deletion packages/commerce/src/api/endpoints/customer/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const customerCardEndpoint: GetAPISchema<
const { cookies } = req

// Cart id might be usefull for anonymous shopping
const cartId = cookies.get(config.cartCookie)
const cartId = cookies.get(config.cartCookie)?.value

// Create or add a card
if (req.method === 'GET') {
Expand Down
11 changes: 9 additions & 2 deletions packages/commerce/src/api/endpoints/customer/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { CustomerSchema } from '../../../types/customer'
import type { GetAPISchema } from '../..'

import { z } from 'zod'
import { parse } from '../../utils'
import validateHandlers from '../../utils/validate-handlers'

Expand All @@ -19,7 +19,14 @@ const customerEndpoint: GetAPISchema<
const body = null
const output = await handlers['getLoggedInCustomer']({ ...ctx, body })

return output ? parse(output, customerSchema) : { status: 204 }
return output
? parse(
output,
z.object({
customer: customerSchema,
})
)
: { status: 204 }
}

export default customerEndpoint
2 changes: 1 addition & 1 deletion packages/commerce/src/api/endpoints/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const signupEndpoint: GetAPISchema<

const input = await getInput(req)
const { cookies } = req
const cartId = cookies.get(config.cartCookie)
const cartId = cookies.get(config.cartCookie)?.value

const body = signupBodySchema.parse({ ...input, cartId })
return handlers['signup']({ ...ctx, body })
Expand Down
2 changes: 1 addition & 1 deletion packages/commerce/src/api/endpoints/wishlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const wishlistEndpoint: GetAPISchema<
const { cookies } = req
const input = await getInput(req)

const customerToken = cookies.get(config.customerCookie)
const customerToken = cookies.get(config.customerCookie)?.value
const products = new URL(req.url).searchParams.get('products')

// Return current wishlist info
Expand Down
4 changes: 2 additions & 2 deletions packages/commercejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"lodash.debounce": "^4.0.8"
},
"peerDependencies": {
"next": "^12",
"next": "^13",
"react": "^18",
"react-dom": "^18"
},
Expand All @@ -71,7 +71,7 @@
"@types/node": "^17.0.8",
"@types/react": "^18.0.14",
"lint-staged": "^12.1.7",
"next": "^12.0.8",
"next": "^13.0.6",
"prettier": "^2.5.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/kibocommerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@
"lodash.debounce": "^4.0.8"
},
"peerDependencies": {
"next": "^12",
"next": "^13",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@babel/core": "^7.20.5",
"@graphql-codegen/cli": "^2.7.0",
"@graphql-codegen/schema-ast": "^2.4.1",
"@graphql-codegen/typescript": "^2.4.2",
Expand All @@ -71,7 +72,7 @@
"@types/react": "^18.0.14",
"graphql": "^16.0.0",
"lint-staged": "^12.1.7",
"next": "^12.0.8",
"next": "^13.0.6",
"prettier": "^2.5.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/kibocommerce/src/api/endpoints/cart/remove-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const removeItem: CartEndpoint['handlers']['removeItem'] = async ({
body: { itemId },
config,
}) => {
const encodedToken = req.cookies.get(config.customerCookie)
const encodedToken = req.cookies.get(config.customerCookie)?.value

const token = encodedToken
? Buffer.from(encodedToken, 'base64').toString('ascii')
: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const updateItem: CartEndpoint['handlers']['updateItem'] = async ({
body: { itemId, item },
config,
}) => {
const encodedToken = req.cookies.get(config.cartCookie)
const encodedToken = req.cookies.get(config.cartCookie)?.value
const token = encodedToken
? Buffer.from(encodedToken, 'base64').toString('ascii')
: null
Expand Down
4 changes: 2 additions & 2 deletions packages/kibocommerce/src/api/utils/cookie-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class CookieHandler {
this.config = config
this.request = req

const encodedToken = req.cookies.get(config.customerCookie)
const encodedToken = req.cookies.get(config.customerCookie)?.value
const token = parseCookie(encodedToken)
this.accessToken = token ? token.accessToken : null
}
Expand All @@ -36,7 +36,7 @@ export default class CookieHandler {
}
isShopperCookieAnonymous() {
const customerCookieKey = this.config.customerCookie
const shopperCookie = this.request.cookies.get(customerCookieKey)
const shopperCookie = this.request.cookies.get(customerCookieKey)?.value
const shopperSession = parseCookie(shopperCookie)
const isAnonymous = shopperSession?.customerAccount ? false : true
return isAnonymous
Expand Down
4 changes: 2 additions & 2 deletions packages/local/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@vercel/commerce": "workspace:*"
},
"peerDependencies": {
"next": "^12",
"next": "^13",
"react": "^18",
"react-dom": "^18"
},
Expand All @@ -62,7 +62,7 @@
"@types/react": "^18.0.14",
"@types/node-fetch": "2.6.2",
"lint-staged": "^12.1.7",
"next": "^12.0.8",
"next": "^13.0.6",
"prettier": "^2.5.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/ordercloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"cookie": "^0.4.1"
},
"peerDependencies": {
"next": "^12",
"next": "^13",
"react": "^18",
"react-dom": "^18"
},
Expand All @@ -66,7 +66,7 @@
"@types/cookie": "^0.4.1",
"@types/node-fetch": "^2.6.2",
"lint-staged": "^12.1.7",
"next": "^12.0.8",
"next": "^13.0.6",
"prettier": "^2.5.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/ordercloud/src/api/endpoints/cart/add-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const addItem: CartEndpoint['handlers']['addItem'] = async ({
config: { restBuyerFetch, cartCookie, tokenCookie },
}) => {
// Get token
let token = req.cookies.get(tokenCookie)
let token = req.cookies.get(tokenCookie)?.value
let headers: any = {}

// Create an order if it doesn't exist
Expand Down
2 changes: 1 addition & 1 deletion packages/ordercloud/src/api/endpoints/cart/get-cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const getCart: CartEndpoint['handlers']['getCart'] = async ({

try {
// Get token
const token = req.cookies.get(tokenCookie)
const token = req.cookies.get(tokenCookie)?.value

// Get cart & line items
const [cart, { Items }] = await Promise.all([
Expand Down
2 changes: 1 addition & 1 deletion packages/ordercloud/src/api/endpoints/cart/remove-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const removeItem: CartEndpoint['handlers']['removeItem'] = async ({
body: { cartId, itemId },
config: { restBuyerFetch, tokenCookie },
}) => {
const token = req.cookies.get(tokenCookie)
const token = req.cookies.get(tokenCookie)?.value

// Remove the item to the order
await restBuyerFetch(
Expand Down
2 changes: 1 addition & 1 deletion packages/ordercloud/src/api/endpoints/cart/update-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const updateItem: CartEndpoint['handlers']['updateItem'] = async ({
body: { cartId, itemId, item },
config: { restBuyerFetch, tokenCookie },
}) => {
const token = req.cookies.get(tokenCookie)
const token = req.cookies.get(tokenCookie)?.value

// Store specs
let specs: RawVariant['Specs'] = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const getProducts: ProductsEndpoint['handlers']['getProducts'] = async ({
body: { search, categoryId },
config: { restBuyerFetch, tokenCookie },
}) => {
const token = req.cookies.get(tokenCookie)
const token = req.cookies.get(tokenCookie)?.value

//Use a dummy base as we only care about the relative path
const url = new URL('/me/products', 'http://a')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({
body: { cartId },
config: { restBuyerFetch },
}) => {
const token = req.cookies.get('token')
const token = req.cookies.get('token')?.value

// Register credit card
const payments = await restBuyerFetch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const submitCheckout: CheckoutEndpoint['handlers']['submitCheckout'] = async ({
body: { cartId },
config: { restBuyerFetch, tokenCookie },
}) => {
const token = req.cookies.get(tokenCookie)
const token = req.cookies.get(tokenCookie)?.value

// Submit order
await restBuyerFetch('POST', `/orders/Outgoing/${cartId}/submit`, null, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const addItem: CustomerAddressEndpoint['handlers']['addItem'] = async ({
body: { item, cartId },
config: { restBuyerFetch, tokenCookie },
}) => {
const token = req.cookies.get(tokenCookie)
const token = req.cookies.get(tokenCookie)?.value

// Register address
const address = await restBuyerFetch('POST', `/me/addresses`, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const addItem: CustomerCardEndpoint['handlers']['addItem'] = async ({
config: { restBuyerFetch, tokenCookie },
}) => {
// Get token
const token = req.cookies.get(tokenCookie)
const token = req.cookies.get(tokenCookie)?.value

const [exp_month, exp_year] = item.cardExpireDate.split('/')
const stripeToken = await fetch('https://api.stripe.com/v1/tokens', {
Expand Down
5 changes: 3 additions & 2 deletions packages/saleor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@
"lodash.debounce": "^4.0.8"
},
"peerDependencies": {
"next": "^12",
"next": "^13",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@babel/core": "^7.20.5",
"@graphql-codegen/cli": "^2.7.0",
"@graphql-codegen/schema-ast": "^2.4.1",
"@graphql-codegen/typescript": "^2.4.2",
Expand All @@ -73,7 +74,7 @@
"@types/react": "^18.0.14",
"graphql": "^16.0.0",
"lint-staged": "^12.1.7",
"next": "^12.0.8",
"next": "^13.0.6",
"prettier": "^2.5.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/sfcc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"commerce-sdk": "^2.7.0"
},
"peerDependencies": {
"next": "^12",
"next": "^13",
"react": "^18",
"react-dom": "^18"
},
Expand All @@ -63,7 +63,7 @@
"@types/react": "^18.0.14",
"@types/node-fetch": "^2.6.2",
"lint-staged": "^12.1.7",
"next": "^12.0.8",
"next": "^13.0.6",
"prettier": "^2.5.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
7 changes: 4 additions & 3 deletions packages/shopify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@
"lodash.debounce": "^4.0.8"
},
"peerDependencies": {
"next": "^12",
"next": "^13",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@babel/core": "^7.20.5",
"@graphql-codegen/cli": "2.7.0",
"@graphql-codegen/schema-ast": "^2.4.1",
"@graphql-codegen/typescript": "^2.6.0",
Expand All @@ -69,10 +70,10 @@
"@types/js-cookie": "3.0.2",
"@types/lodash.debounce": "^4.0.7",
"@types/node": "^18.0.3",
"@types/react": "^18.0.14",
"@types/node-fetch": "2.6.2",
"graphql": "^16.0.0",
"@types/react": "^18.0.14",
"dotenv": "^16.0.1",
"graphql": "^16.0.0",
"lint-staged": "^13.0.3",
"next": "^12.2.1",
"prettier": "^2.7.1",
Expand Down
Loading

0 comments on commit 4efa502

Please sign in to comment.