Added types to database/gitlab

This commit is contained in:
dominicbachmann 2022-04-06 20:01:35 +02:00
parent b4f98e24a1
commit c390f82246

View File

@ -1,7 +1,14 @@
import { encrypt } from '$lib/crypto'; import { encrypt } from '$lib/crypto';
import { generateSshKeyPair, prisma } from './common'; 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<GitlabApp> {
const application = await prisma.application.findUnique({ const application = await prisma.application.findUnique({
where: { id }, where: { id },
include: { gitSource: { include: { gitlabApp: true } } } include: { gitSource: { include: { gitlabApp: true } } }
@ -11,14 +18,24 @@ export async function updateDeployKey({ id, deployKeyId }) {
data: { 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({ const application = await prisma.application.findUnique({
where: { id }, where: { id },
include: { gitSource: { include: { gitlabApp: true } } } include: { gitSource: { include: { gitlabApp: true } } }
}); });
return { status: 200, body: { publicKey: application.gitSource.gitlabApp.publicSshKey } }; 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({ const application = await prisma.application.findUnique({
where: { id }, where: { id },
include: { gitSource: { include: { gitlabApp: true } } } include: { gitSource: { include: { gitlabApp: true } } }