mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 16:28:11 +00:00
26 lines
747 B
TypeScript
26 lines
747 B
TypeScript
import { Knex } from "knex";
|
|
|
|
import { TDbClient } from "@app/db";
|
|
import { TableName } from "@app/db/schemas";
|
|
import { DatabaseError } from "@app/lib/errors";
|
|
import { ormify } from "@app/lib/knex";
|
|
|
|
export type TKmsRootConfigDALFactory = ReturnType<typeof kmsRootConfigDALFactory>;
|
|
|
|
export const kmsRootConfigDALFactory = (db: TDbClient) => {
|
|
const kmsOrm = ormify(db, TableName.KmsServerRootConfig);
|
|
|
|
const findById = async (id: string, tx?: Knex) => {
|
|
try {
|
|
const result = await (tx || db)(TableName.KmsServerRootConfig)
|
|
.where({ id } as never)
|
|
.first("*");
|
|
return result;
|
|
} catch (error) {
|
|
throw new DatabaseError({ error, name: "Find by id" });
|
|
}
|
|
};
|
|
|
|
return { ...kmsOrm, findById };
|
|
};
|