Skip to content

Commit

Permalink
Merge branch 'MEP-4859' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrMurdzia committed Apr 26, 2024
2 parents 7d69fc6 + bb382c8 commit 6079057
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Credentials/controllers/receiving/Create.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { checkIfRequestBodyExists, checkIfPositiveIntegerNumber, checkIfTypeIsString } from "../../../_common/utils/Request.utils";
import { checkIfPositiveIntegerNumber, checkIfRequestBodyExists, checkIfTypeIsString } from "../../../_common/utils/Request.utils";

import { HttpRequest } from "@azure/functions";
import ReceivingCredential from '../../../_common/models/ReceivingCredential.model';
Expand All @@ -21,11 +21,17 @@ export const createReceive = async (req: HttpRequest) => {
checkIfTypeIsString(username, 'username');

// Check if row with id_account already exists
const response_from_db = await ReceivingCredential.get(id_account);
let response_from_db = await ReceivingCredential.get(id_account);

// If exists throw error 409 - Conflict
throwIfDatabaseResourceExists(response_from_db, 'id_account');

// Check if row with uuid already exists
response_from_db = await ReceivingCredential.getUUID(uuid);

// If exists throw error 409 - Conflict
throwIfDatabaseResourceExists(response_from_db, 'uuid');

await ReceivingCredential.create(id_account, uuid, username);

return {
Expand Down
7 changes: 7 additions & 0 deletions Credentials/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AzureFunction, Context, HttpRequest } from "@azure/functions"

import { ErrorLogs } from "../_common/models/ErrorLogs.model";
import { create } from "./controllers/fetching/Create";
import { createReceive } from "./controllers/receiving/Create";
import { get } from "./controllers/fetching/Get";
Expand Down Expand Up @@ -86,6 +87,12 @@ const httpTrigger: AzureFunction = async function (context: Context, req: HttpRe
'Content-Type': 'application/json'
}
};

ErrorLogs.insert(
{ error: error, req: req },
'Unexpected error occurred.',
'--- Internal error ---'
);
}
};

Expand Down

0 comments on commit 6079057

Please sign in to comment.