An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Added types for database/gitSource
dominicbachmannc4cb92c78dc6
diff --git a/src/lib/database/gitSources.ts b/src/lib/database/gitSources.tsindex 927907964e..2d165b974c 100644--- a/src/lib/database/gitSources.ts+++ b/src/lib/database/gitSources.ts@@ -1,14 +1,31 @@import { decrypt, encrypt } from '$lib/crypto';import { prisma } from './common';+import type { GithubApp, GitlabApp, GitSource, Prisma, Application } from '@prisma/client';-export async function listSources(teamId) {+export async function listSources(+ teamId: string | Prisma.StringFilter+): Promise<(GitSource & { githubApp?: GithubApp; gitlabApp?: GitlabApp })[]> {return await prisma.gitSource.findMany({where: { teams: { some: { id: teamId } } },include: { githubApp: true, gitlabApp: true }});}-export async function newSource({ name, teamId, type, htmlUrl, apiUrl, organization }) {+export async function newSource({+ name,+ teamId,+ type,+ htmlUrl,+ apiUrl,+ organization+}: {+ name: string;+ teamId: string;+ type: string;+ htmlUrl: string;+ apiUrl: string;+ organization: string;+}): Promise<GitSource> {return await prisma.gitSource.create({data: {teams: { connect: { id: teamId } },@@ -20,7 +37,7 @@ export async function newSource({ name, teamId, type, htmlUrl, apiUrl, organizat}});}-export async function removeSource({ id }) {+export async function removeSource({ id }: { id: string }): Promise<void> {// TODO: Disconnect application with this sourceId! Maybe not needed?const source = await prisma.gitSource.delete({where: { id },@@ -30,8 +47,14 @@ export async function removeSource({ id }) {if (source.gitlabAppId) await prisma.gitlabApp.delete({ where: { id: source.gitlabAppId } });}-export async function getSource({ id, teamId }) {- let body = await prisma.gitSource.findFirst({+export async function getSource({+ id,+ teamId+}: {+ id: string;+ teamId: string;+}): Promise<GitSource & { githubApp: GithubApp; gitlabApp: GitlabApp }> {+ const body = await prisma.gitSource.findFirst({where: { id, teams: { some: { id: teamId } } },include: { githubApp: true, gitlabApp: true }});@@ -43,27 +66,53 @@ export async function getSource({ id, teamId }) {if (body?.gitlabApp?.appSecret) body.gitlabApp.appSecret = decrypt(body.gitlabApp.appSecret);return body;}-export async function addSource({ id, appId, teamId, oauthId, groupName, appSecret }) {- const encrptedAppSecret = encrypt(appSecret);+export async function addSource({+ id,+ appId,+ teamId,+ oauthId,+ groupName,+ appSecret+}: {+ id: string;+ appId: string;+ teamId: string;+ oauthId: number;+ groupName: string;+ appSecret: string;+}): Promise<GitlabApp> {+ const encryptedAppSecret = encrypt(appSecret);return await prisma.gitlabApp.create({data: {teams: { connect: { id: teamId } },appId,oauthId,groupName,- appSecret: encrptedAppSecret,+ appSecret: encryptedAppSecret,gitSource: { connect: { id } }}});}-export async function configureGitsource({ id, gitSourceId }) {+export async function configureGitsource({+ id,+ gitSourceId+}: {+ id: string;+ gitSourceId: string;+}): Promise<Application> {return await prisma.application.update({where: { id },data: { gitSource: { connect: { id: gitSourceId } } }});}-export async function updateGitsource({ id, name }) {+export async function updateGitsource({+ id,+ name+}: {+ id: string;+ name: string;+}): Promise<GitSource> {return await prisma.gitSource.update({where: { id },data: { name }