2
0

Add OpenAI block

Also migrate credentials to tRPC

Closes #253
This commit is contained in:
Baptiste Arnaud
2023-03-09 08:46:36 +01:00
parent 97cfdfe79f
commit ff04edf139
86 changed files with 2583 additions and 1055 deletions

View File

@ -3,7 +3,6 @@ import { Prisma } from 'db'
import prisma from '@/lib/prisma'
import { googleSheetsScopes } from './consent-url'
import { stringify } from 'querystring'
import { CredentialsType } from 'models'
import { badRequest, encrypt, notAuthenticated } from 'utils/api'
import { oauth2Client } from '@/lib/googleSheets'
import { getAuthenticatedUser } from '@/features/auth/api'
@ -41,11 +40,11 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const { encryptedData, iv } = encrypt(tokens)
const credentials = {
name: email,
type: CredentialsType.GOOGLE_SHEETS,
type: 'google sheets',
workspaceId,
data: encryptedData,
iv,
} as Prisma.CredentialsUncheckedCreateInput
} satisfies Prisma.CredentialsUncheckedCreateInput
const { id: credentialsId } = await prisma.credentials.create({
data: credentials,
})