mirror of
https://github.com/documenso/documenso.git
synced 2025-11-26 14:34:05 +10:00
chore: telemetry (#2240)
This commit is contained in:
22
packages/lib/server-only/site-settings/get-site-setting.ts
Normal file
22
packages/lib/server-only/site-settings/get-site-setting.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
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;
|
||||
};
|
||||
Reference in New Issue
Block a user