2
0

build: add pnpm

This commit is contained in:
Baptiste Arnaud
2022-08-08 08:21:36 +02:00
parent 8c3b5058f1
commit ee338f62dc
183 changed files with 19442 additions and 18364 deletions

View File

@ -15,7 +15,10 @@ import { env, isNotEmpty } from 'utils'
const providers: Provider[] = []
if (isNotEmpty(process.env.GITHUB_CLIENT_ID))
if (
isNotEmpty(process.env.GITHUB_CLIENT_ID) &&
isNotEmpty(process.env.GITHUB_CLIENT_SECRET)
)
providers.push(
GitHubProvider({
clientId: process.env.GITHUB_CLIENT_ID,

View File

@ -10,7 +10,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const workspaceId = req.query.workspaceId as string | undefined
if (!workspaceId) return badRequest(res)
if (req.method === 'DELETE') {
const credentialsId = req.query.credentialsId.toString()
const credentialsId = req.query.credentialsId as string | undefined
const credentials = await prisma.credentials.deleteMany({
where: {
id: credentialsId,

View File

@ -12,8 +12,10 @@ import { getAuthenticatedUser } from 'services/api/utils'
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const user = await getAuthenticatedUser(req)
if (!user) return notAuthenticated(res)
const state = req.query.state as string | undefined
if (!state) return badRequest(res)
const { redirectUrl, blockId, workspaceId } = JSON.parse(
Buffer.from(req.query.state.toString(), 'base64').toString()
Buffer.from(state, 'base64').toString()
)
if (req.method === 'GET') {
const code = req.query.code as string | undefined

View File

@ -11,7 +11,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const workspaceId = req.query.workspaceId as string | undefined
if (!workspaceId) return badRequest(res)
if (req.method === 'DELETE') {
const domain = req.query.domain.toString()
const domain = req.query.domain as string
try {
await deleteDomainOnVercel(domain)
} catch {}

View File

@ -9,7 +9,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const user = await getAuthenticatedUser(req)
if (!user) return notAuthenticated(res)
const id = req.query.id.toString()
const id = req.query.id as string
if (req.method === 'GET') {
const folder = await prisma.dashboardFolder.findFirst({
where: {

View File

@ -1,6 +1,5 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { drive } from '@googleapis/drive'
import { OAuth2Client } from 'googleapis-common'
import { getAuthenticatedGoogleClient } from 'libs/google-sheets'
import { badRequest, methodNotAllowed, notAuthenticated } from 'utils'
import { setUser, withSentry } from '@sentry/nextjs'
@ -19,7 +18,9 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
return res.status(404).send("Couldn't find credentials in database")
const response = await drive({
version: 'v3',
auth: auth.client as unknown as OAuth2Client,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
auth: auth.client,
}).files.list({
q: "mimeType='application/vnd.google-apps.spreadsheet'",
fields: 'nextPageToken, files(id, name)',

View File

@ -4,8 +4,8 @@ import { methodNotAllowed } from 'utils'
const handler = (req: NextApiRequest, res: NextApiResponse) => {
if (req.method === 'POST') {
const firstParam = req.query.firstParam.toString()
const secondParam = req.query.secondParam.toString()
const firstParam = req.query.firstParam?.toString()
const secondParam = req.query.secondParam?.toString()
const customHeader = req.headers['custom-typebot']
const { body } = req
if (

View File

@ -1,7 +1,12 @@
import { withSentry } from '@sentry/nextjs'
import { NextApiRequest, NextApiResponse } from 'next'
import { getSession } from 'next-auth/react'
import { badRequest, generatePresignedUrl, methodNotAllowed } from 'utils'
import { getAuthenticatedUser } from 'services/api/utils'
import {
badRequest,
generatePresignedUrl,
methodNotAllowed,
notAuthenticated,
} from 'utils'
const handler = async (
req: NextApiRequest,
@ -9,11 +14,8 @@ const handler = async (
): Promise<void> => {
res.setHeader('Access-Control-Allow-Origin', '*')
if (req.method === 'GET') {
const session = await getSession({ req })
if (!session) {
res.status(401)
return
}
const user = await getAuthenticatedUser(req)
if (!user) return notAuthenticated(res)
if (
!process.env.S3_ENDPOINT ||

View File

@ -8,7 +8,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
if (!process.env.STRIPE_SECRET_KEY)
throw Error('STRIPE_SECRET_KEY var is missing')
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2020-08-27',
apiVersion: '2022-08-01',
})
const { email, currency, plan, workspaceId, href } =
typeof req.body === 'string' ? JSON.parse(req.body) : req.body

View File

@ -27,7 +27,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
})
if (!workspace?.stripeId) return forbidden(res)
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2020-08-27',
apiVersion: '2022-08-01',
})
const session = await stripe.billingPortal.sessions.create({
customer: workspace.stripeId,

View File

@ -13,7 +13,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
if (!process.env.STRIPE_SECRET_KEY)
throw Error('STRIPE_SECRET_KEY var is missing')
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2020-08-27',
apiVersion: '2022-08-01',
})
const subscriptions = await stripe.subscriptions.list({
customer: customerId,

View File

@ -10,7 +10,7 @@ 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')
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2020-08-27',
apiVersion: '2022-08-01',
})
const cors = Cors({

View File

@ -10,7 +10,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const user = await getAuthenticatedUser(req)
if (!user) return notAuthenticated(res)
const typebotId = req.query.typebotId.toString()
const typebotId = req.query.typebotId as string
if (req.method === 'GET') {
const typebot = await prisma.typebot.findFirst({
where: canReadTypebot(typebotId, user),

View File

@ -66,7 +66,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
await prisma.invitation.create({
data: { email: email.toLowerCase().trim(), type, typebotId },
})
if (env('E2E_TEST') !== 'enabled')
if (env('E2E_TEST') !== 'true')
await sendEmailNotification({
to: email,
subject: "You've been invited to collaborate 🤝",

View File

@ -23,9 +23,9 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
})
if (!workspace) return forbidden(res)
if (req.method === 'GET') {
const typebotId = req.query.typebotId.toString()
const typebotId = req.query.typebotId as string
const lastResultId = req.query.lastResultId?.toString()
const take = parseInt(req.query.limit?.toString())
const take = Number(req.query.limit?.toString())
const results = await prisma.result.findMany({
take: isNaN(take) ? undefined : take,
skip: lastResultId ? 1 : 0,

View File

@ -10,7 +10,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const user = await getAuthenticatedUser(req)
if (!user) return notAuthenticated(res)
if (req.method === 'GET') {
const typebotId = req.query.typebotId.toString()
const typebotId = req.query.typebotId as string
const typebot = await prisma.typebot.findFirst({
where: canReadTypebot(typebotId, user),
include: { publishedTypebot: true },

View File

@ -10,7 +10,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const user = await getAuthenticatedUser(req)
if (!user) return notAuthenticated(res)
if (req.method === 'GET') {
const typebotId = req.query.typebotId.toString()
const typebotId = req.query.typebotId as string
const totalViews = await prisma.result.count({
where: {

View File

@ -8,7 +8,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const user = await getAuthenticatedUser(req)
if (!user) return notAuthenticated(res)
const id = req.query.userId.toString()
const id = req.query.userId as string
if (req.method === 'PUT') {
const data = typeof req.body === 'string' ? JSON.parse(req.body) : req.body
const typebots = await prisma.user.update({

View File

@ -9,7 +9,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
if (!user) return notAuthenticated(res)
if (req.method === 'DELETE') {
const id = req.query.tokenId.toString()
const id = req.query.tokenId as string
const apiToken = await prisma.apiToken.delete({
where: { id },
})