Files
triggerdotdev--trigger.dev/apps/webapp/app/models/runtimeEnvironment.server.ts
Matt Aitken 9ff4c0dbd5 Project-wide Prettier setup (#237)
* Setup project-wide prettier

* Remove old workspace file

* Remove old debugging directives

* New top-level .prettierignore

* Updated Prettier config settings

* Contrubuting guide: Fix for some bad code blocks

* Added more ignores

* Improved the format script command

* printWidth set to 100

* Formatted entire repo (pnpm run format)
2023-08-01 10:21:22 +01:00

52 lines
1.1 KiB
TypeScript

import type { RuntimeEnvironment } from "@trigger.dev/database";
import { prisma } from "~/db.server";
export type { RuntimeEnvironment };
export async function findEnvironmentByApiKey(apiKey: string) {
const environment = await prisma.runtimeEnvironment.findUnique({
where: {
apiKey,
},
include: {
project: true,
organization: true,
},
});
return environment;
}
export async function findEnvironmentByPublicApiKey(apiKey: string) {
const environment = await prisma.runtimeEnvironment.findUnique({
where: {
pkApiKey: apiKey,
},
include: {
project: true,
organization: true,
},
});
return environment;
}
export async function getEnvironmentForOrganization(organizationSlug: string, slug: string) {
const organization = await prisma.organization.findUnique({
where: {
slug: organizationSlug,
},
include: {
environments: true,
},
});
if (!organization) {
return;
}
const environment = organization.environments.find((environment) => environment.slug === slug);
return environment;
}