2
0

build: 🏗️ Add Sentry to builder

This commit is contained in:
Baptiste Arnaud
2022-02-14 10:57:57 +01:00
parent 5a060c7f7e
commit 8501d39234
31 changed files with 474 additions and 52 deletions

View File

@ -1,12 +1,10 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { methodNotAllowed } from 'utils'
import Stripe from 'stripe'
import { withSentry } from '@sentry/nextjs'
const usdPriceIdTest = 'price_1Jc4TQKexUFvKTWyGvsH4Ff5'
const createCheckoutSession = async (
req: NextApiRequest,
res: NextApiResponse
) => {
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
if (req.method === 'POST') {
if (!process.env.STRIPE_SECRET_KEY)
throw Error('STRIPE_SECRET_KEY var is missing')
@ -32,4 +30,4 @@ const createCheckoutSession = async (
return methodNotAllowed(res)
}
export default createCheckoutSession
export default withSentry(handler)

View File

@ -3,11 +3,9 @@ import { NextApiRequest, NextApiResponse } from 'next'
import { getSession } from 'next-auth/react'
import { methodNotAllowed } from 'utils'
import Stripe from 'stripe'
import { withSentry } from '@sentry/nextjs'
const createCheckoutSession = async (
req: NextApiRequest,
res: NextApiResponse
) => {
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const session = await getSession({ req })
if (!session?.user)
return res.status(401).json({ message: 'Not authenticated' })
@ -29,4 +27,4 @@ const createCheckoutSession = async (
return methodNotAllowed(res)
}
export default createCheckoutSession
export default withSentry(handler)

View File

@ -5,6 +5,7 @@ import Cors from 'micro-cors'
import { buffer } from 'micro'
import prisma from 'libs/prisma'
import { Plan } from 'db'
import { withSentry } from '@sentry/nextjs'
if (!process.env.STRIPE_SECRET_KEY || !process.env.STRIPE_WEBHOOK_SECRET)
throw new Error('STRIPE_SECRET_KEY or STRIPE_WEBHOOK_SECRET missing')
@ -70,4 +71,4 @@ const webhookHandler = async (req: NextApiRequest, res: NextApiResponse) => {
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export default cors(webhookHandler as any)
export default withSentry(cors(webhookHandler as any))