mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 19:16:22 +00:00
feat: fixed eslint and resolved all eslint issues
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { TDbClient } from "@app/db";
|
||||
import { TableName, TProjectKeys } from "@app/db/schemas";
|
||||
import { DatabaseError } from "@app/lib/errors";
|
||||
import { ormify } from "@app/lib/knex";
|
||||
import { ormify, selectAllTableCols } from "@app/lib/knex";
|
||||
|
||||
export type TProjectKeyDALFactory = ReturnType<typeof projectKeyDALFactory>;
|
||||
|
||||
@@ -11,25 +11,23 @@ export const projectKeyDALFactory = (db: TDbClient) => {
|
||||
const findLatestProjectKey = async (
|
||||
userId: string,
|
||||
projectId: string
|
||||
): Promise<TProjectKeys & { sender: { publicKey: string } }> => {
|
||||
): Promise<(TProjectKeys & { sender: { publicKey: string } }) | undefined> => {
|
||||
try {
|
||||
const projectKey = await db(TableName.ProjectKeys)
|
||||
.where({ projectId, receiverId: userId })
|
||||
.join(TableName.Users, `${TableName.ProjectKeys}.senderId`, `${TableName.Users}.id`)
|
||||
.join(
|
||||
TableName.UserEncryptionKey,
|
||||
`${TableName.UserEncryptionKey}.userId`,
|
||||
`${TableName.Users}.id`
|
||||
)
|
||||
.where({ projectId, receiverId: userId })
|
||||
.orderBy("createdAt", "desc", "last")
|
||||
.select(`${TableName.ProjectKeys}.*`, `${TableName.UserEncryptionKey}.publicKey`)
|
||||
.select(selectAllTableCols(TableName.ProjectKeys))
|
||||
.select(db.ref("publicKey").withSchema(TableName.UserEncryptionKey))
|
||||
.first();
|
||||
if (projectKey) {
|
||||
projectKey.sender = {
|
||||
publicKey: projectKey.publicKey
|
||||
};
|
||||
return { ...projectKey, sender: { publicKey: projectKey.publicKey } };
|
||||
}
|
||||
return projectKey;
|
||||
} catch (error) {
|
||||
throw new DatabaseError({ error, name: "Find latest project key" });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user