1
0
mirror of https://github.com/vercel/commerce.git synced 2025-07-28 12:41:22 +00:00
Files
.vscode
assets
components
config
framework
bigcommerce
commerce
local
shopify
swell
api
cart
catalog
checkout
index.ts
customers
operations
utils
wishlist
customer.ts
index.ts
auth
cart
common
customer
product
utils
wishlist
.env.template
commerce.config.json
const.ts
fetcher.ts
index.tsx
next.config.js
provider.ts
schema.d.ts
schema.graphql
swell-js.d.ts
types.ts
vendure
lib
pages
public
.editorconfig
.env.template
.gitignore
.prettierignore
.prettierrc
README.md
codegen.json
commerce.config.json
global.d.ts
license.md
next-env.d.ts
next.config.js
package-lock.json
package.json
postcss.config.js
tailwind.config.js
tsconfig.json
yarn.lock
commerce/framework/swell/api/checkout/index.ts
2021-04-25 16:34:29 -05:00

21 lines
498 B
TypeScript

import createApiHandler, { SwellApiHandler } from '../utils/create-api-handler'
import { SWELL_CHECKOUT_URL_COOKIE } from '../../const'
import { getConfig } from '..'
const checkoutApi: SwellApiHandler<any> = async (req, res, config) => {
config = getConfig()
const { cookies } = req
const checkoutUrl = cookies[SWELL_CHECKOUT_URL_COOKIE]
if (checkoutUrl) {
res.redirect(checkoutUrl)
} else {
res.redirect('/cart')
}
}
export default createApiHandler(checkoutApi, {}, {})