From c390f82246d310e4e6bf239722a8934cf6d0b640 Mon Sep 17 00:00:00 2001 From: dominicbachmann Date: Wed, 6 Apr 2022 20:01:35 +0200 Subject: [PATCH] Added types to database/gitlab --- src/lib/database/gitlab.ts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/lib/database/gitlab.ts b/src/lib/database/gitlab.ts index eb9bdfb1b..8bb6a9c9b 100644 --- a/src/lib/database/gitlab.ts +++ b/src/lib/database/gitlab.ts @@ -1,7 +1,14 @@ import { encrypt } from '$lib/crypto'; import { generateSshKeyPair, prisma } from './common'; +import type { GitlabApp } from '@prisma/client'; -export async function updateDeployKey({ id, deployKeyId }) { +export async function updateDeployKey({ + id, + deployKeyId +}: { + id: string; + deployKeyId: number; +}): Promise { const application = await prisma.application.findUnique({ where: { id }, include: { gitSource: { include: { gitlabApp: true } } } @@ -11,14 +18,24 @@ export async function updateDeployKey({ id, deployKeyId }) { data: { deployKeyId } }); } -export async function getSshKey({ id }) { +export async function getSshKey({ + id +}: { + id: string; +}): Promise<{ status: number; body: { publicKey: string } }> { const application = await prisma.application.findUnique({ where: { id }, include: { gitSource: { include: { gitlabApp: true } } } }); return { status: 200, body: { publicKey: application.gitSource.gitlabApp.publicSshKey } }; } -export async function generateSshKey({ id }) { +export async function generateSshKey({ + id +}: { + id: string; +}): Promise< + { status: number; body: { publicKey: string } } | { status: number; body?: undefined } +> { const application = await prisma.application.findUnique({ where: { id }, include: { gitSource: { include: { gitlabApp: true } } }