feat: fixed eslint and resolved all eslint issues

This commit is contained in:
Akhil Mohan
2024-01-30 22:30:42 +05:30
parent 7c4dd5000f
commit 5855cc660a
147 changed files with 1165 additions and 938 deletions
@@ -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" });
}