mirror of
https://github.com/documenso/documenso.git
synced 2025-11-26 22:44:41 +10:00
23 lines
564 B
TypeScript
23 lines
564 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
|
|
import type { TSiteSettingSchema } from './schema';
|
|
import { ZSiteSettingSchema } from './schema';
|
|
|
|
export const getSiteSetting = async <
|
|
T extends TSiteSettingSchema['id'],
|
|
U = Extract<TSiteSettingSchema, { id: T }>,
|
|
>(options: {
|
|
id: T;
|
|
}): Promise<U> => {
|
|
const { id } = options;
|
|
|
|
const setting = await prisma.siteSettings.findFirstOrThrow({
|
|
where: {
|
|
id,
|
|
},
|
|
});
|
|
|
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
return ZSiteSettingSchema.parse(setting) as U;
|
|
};
|