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 17, 2024
2 parents 589e912 + 42db80b commit 01313af
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Credentials/controllers/receiving/Create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const createReceive = async (req: HttpRequest) => {
// Chack body params
checkReceivingRequestBodyParamsForCreateOrUpdate(uuid, username, id_account);

checkIfTypeIsNumber(id_account, 'id_account');
checkIfTypeIsNumber(Number(id_account), 'id_account');

checkIfTypeIsString(uuid, 'uuid');

Expand All @@ -24,7 +24,7 @@ export const createReceive = async (req: HttpRequest) => {
const response_from_db = await ReceivingCredential.get(id_account);

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

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

Expand Down
2 changes: 1 addition & 1 deletion Credentials/controllers/receiving/Get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const getReceive = async (req: HttpRequest) => {
// Chack body params
checkReceivingRequestQueryParamsForGet(id_account);

checkIfTypeIsNumber(id_account, 'id_account');
checkIfTypeIsNumber(Number(id_account), 'id_account');

// Check if row with id_account already exists
const response_from_db = await ReceivingCredential.get(Number(id_account));
Expand Down
2 changes: 1 addition & 1 deletion Credentials/controllers/receiving/Remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const removeReceive = async (req: HttpRequest) => {
// Chack body params
checkReceivingRequestBodyParamsForDelete(id_account);

checkIfTypeIsNumber(id_account, 'id_account');
checkIfTypeIsNumber(Number(id_account), 'id_account');

// Check if row with id_account already exists
let response_from_db = await ReceivingCredential.get(Number(id_account));
Expand Down
2 changes: 1 addition & 1 deletion Credentials/controllers/receiving/Update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const updateReceive = async (req: HttpRequest) => {

const { uuid, username, id_account } = req.body;

checkIfTypeIsNumber(id_account, 'id_account');
checkIfTypeIsNumber(Number(id_account), 'id_account');

// Chack body params
checkReceivingRequestBodyParamsForCreateOrUpdate(uuid, username, id_account);
Expand Down
9 changes: 6 additions & 3 deletions _common/models/ReceivingCredential.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as AzureStorage from 'azure-storage';

import { CONNECTION_STRING } from '../parameters/EnvParameters';
import { ErrorLogs } from './ErrorLogs.model';
import { v4 as uuidv4 } from 'uuid';

export default class ReceivingCredential {
private static table_name = 'receivingCredentials';
Expand All @@ -17,13 +18,15 @@ export default class ReceivingCredential {
* @returns A promise that resolves with the result of the creation.
*/
static create = async (id_account: number, uuid: string, username: string) => {
const rowKey = uuidv4();

// Create an entity object
const object = {
RowKey: id_account,
PartitionKey: id_account,
RowKey: rowKey,
PartitionKey: rowKey,
uuid: uuid,
id_account: id_account,
username: username,
id_account: id_account,
created_at: new Date().toISOString()
};

Expand Down
23 changes: 18 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"azure-storage": "^2.10.7",
"crypto-js": "^4.1.1",
"jsonwebtoken": "^9.0.2",
"jwks-rsa": "^3.1.0"
"jwks-rsa": "^3.1.0",
"uuid": "^9.0.1"
},
"devDependencies": {
"@azure/functions": "^3.0.0",
Expand Down

0 comments on commit 01313af

Please sign in to comment.