From b4f98e24a18b0d03b06a6973b18f870f88b7c01d Mon Sep 17 00:00:00 2001 From: dominicbachmann Date: Wed, 6 Apr 2022 19:56:47 +0200 Subject: [PATCH] Added types to database/github --- src/lib/database/github.ts | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/lib/database/github.ts b/src/lib/database/github.ts index 339b8e008..182ad4529 100644 --- a/src/lib/database/github.ts +++ b/src/lib/database/github.ts @@ -1,7 +1,15 @@ import { decrypt, encrypt } from '$lib/crypto'; import { prisma } from './common'; +import type { GithubApp } from '@prisma/client'; -export async function addInstallation({ gitSourceId, installation_id }) { +// TODO: We should change installation_id to be camelCase +export async function addInstallation({ + gitSourceId, + installation_id +}: { + gitSourceId: string; + installation_id: string; +}): Promise { const source = await prisma.gitSource.findUnique({ where: { id: gitSourceId }, include: { githubApp: true } @@ -12,8 +20,12 @@ export async function addInstallation({ gitSourceId, installation_id }) { }); } -export async function getUniqueGithubApp({ githubAppId }) { - let body = await prisma.githubApp.findUnique({ where: { id: githubAppId } }); +export async function getUniqueGithubApp({ + githubAppId +}: { + githubAppId: string; +}): Promise { + const body = await prisma.githubApp.findUnique({ where: { id: githubAppId } }); if (body.privateKey) body.privateKey = decrypt(body.privateKey); return body; } @@ -26,7 +38,15 @@ export async function createGithubApp({ pem, webhook_secret, state -}) { +}: { + id: number; + client_id: string; + slug: string; + client_secret: string; + pem: string; + webhook_secret: string; + state: string; +}): Promise { const encryptedClientSecret = encrypt(client_secret); const encryptedWebhookSecret = encrypt(webhook_secret); const encryptedPem = encrypt(pem);