Revert "Revert "feat(api): better errors and documentation""

This commit is contained in:
Maidul Islam
2024-09-30 12:58:57 -04:00
committed by GitHub
parent 7e11fbe7a3
commit 3a6e79c575
107 changed files with 979 additions and 854 deletions
@@ -4,7 +4,7 @@ import bcrypt from "bcrypt";
import { TApiKeys } from "@app/db/schemas/api-keys";
import { getConfig } from "@app/lib/config/env";
import { BadRequestError, UnauthorizedError } from "@app/lib/errors";
import { NotFoundError, UnauthorizedError } from "@app/lib/errors";
import { TUserDALFactory } from "../user/user-dal";
import { TApiKeyDALFactory } from "./api-key-dal";
@@ -45,7 +45,7 @@ export const apiKeyServiceFactory = ({ apiKeyDAL, userDAL }: TApiKeyServiceFacto
const deleteApiKey = async (userId: string, apiKeyId: string) => {
const [apiKeyData] = await apiKeyDAL.delete({ id: apiKeyId, userId });
if (!apiKeyData) throw new BadRequestError({ message: "Failed to find api key", name: "delete api key" });
if (!apiKeyData) throw new NotFoundError({ message: "API key not found" });
return formatApiKey(apiKeyData);
};