Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stage #8

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d9ef9a1
Status adjustment and added version parameter to health endpoint
przemyslawss Mar 21, 2024
69e1994
Updated gitignore
przemyslawss Mar 21, 2024
54f10e4
Status change
przemyslawss Mar 22, 2024
002e67d
service refactor
przemyslawss Apr 3, 2024
30e1c32
added enders
przemyslawss Apr 3, 2024
f3a3ceb
Merge pull request #1 from OpusCapita/feature/refactor
przemyslawss Apr 3, 2024
943a203
MEP-4859
PiotrMurdzia Apr 11, 2024
79e81bd
Merge branch 'MEP-4859' into dev
PiotrMurdzia Apr 11, 2024
33d4650
Receive - update flow
PiotrMurdzia Apr 12, 2024
dcdcc93
Merge branch 'MEP-4859' into dev
PiotrMurdzia Apr 12, 2024
3d0f3f2
Receiving is based on id_account as ID
PiotrMurdzia Apr 17, 2024
b7f2196
Merge branch 'MEP-4859' into dev
PiotrMurdzia Apr 17, 2024
09b13ad
New method - getAll receiving TM configurations
PiotrMurdzia Apr 17, 2024
589e912
Merge branch 'MEP-4859' into dev
PiotrMurdzia Apr 17, 2024
42db80b
Fix
PiotrMurdzia Apr 17, 2024
01313af
Merge branch 'MEP-4859' into dev
PiotrMurdzia Apr 17, 2024
d620564
Response data typy
PiotrMurdzia Apr 17, 2024
565c20a
Merge branch 'MEP-4859' into dev
PiotrMurdzia Apr 17, 2024
90970c8
Response: 'Content-Type': 'application/json'
PiotrMurdzia Apr 17, 2024
de7d8f3
Merge branch 'MEP-4859' into dev
PiotrMurdzia Apr 17, 2024
ef98051
add field_name into error responses
PiotrMurdzia Apr 17, 2024
6e44367
Merge branch 'MEP-4859' into dev
PiotrMurdzia Apr 17, 2024
43fc3a2
V++
PiotrMurdzia Apr 17, 2024
f6934f6
Error response headers
PiotrMurdzia Apr 17, 2024
d0ccb8f
Merge branch 'dev' into MEP-4859
PiotrMurdzia Apr 23, 2024
9e503bf
fix
przemyslawss Apr 24, 2024
1eab32b
Merge pull request #3 from OpusCapita/MEP-4859
przemyslawss Apr 24, 2024
e8c3274
fix for number id_account being string
przemyslawss Apr 25, 2024
ba48fcc
fix for string and number id_account MEP-4859
przemyslawss Apr 25, 2024
7e4b4c9
Merge pull request #5 from OpusCapita/MEP-4859
przemyslawss Apr 25, 2024
314e9c1
MEP-4859
przemyslawss Apr 25, 2024
5ed5292
Merge pull request #7 from OpusCapita/MEP-4859
przemyslawss Apr 25, 2024
6303b0c
Merge branch 'dev' into stage
PiotrMurdzia Apr 26, 2024
dea3586
Receive Get - support uuid & id_account
PiotrMurdzia Apr 26, 2024
7d69fc6
Merge branch 'MEP-4859' into dev
PiotrMurdzia Apr 26, 2024
bb382c8
Unique uuid for Receiving Credentials + Global ErrorLog
PiotrMurdzia Apr 26, 2024
6079057
Merge branch 'MEP-4859' into dev
PiotrMurdzia Apr 26, 2024
aae0584
Create Receiving Credentials - unique username validation
PiotrMurdzia Apr 26, 2024
8bc9a49
Merge branch 'MEP-4859' into dev
PiotrMurdzia Apr 26, 2024
4e62d03
Receiving update -> validation if unique username & uuid
PiotrMurdzia Apr 26, 2024
1dc0dcc
Merge branch 'MEP-4859' into dev
PiotrMurdzia Apr 26, 2024
ed8e1ca
file_name => field_name
PiotrMurdzia Apr 26, 2024
6d82713
Merge branch 'MEP-4859' into dev
PiotrMurdzia Apr 26, 2024
c32c2c1
Merge branch 'dev' into stage
PiotrMurdzia Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,6 @@ appsettings.json
__blobstorage__
__queuestorage__
__azurite_db*__.json

# files
local.settings.json
58 changes: 22 additions & 36 deletions Credentials/controllers/fetching/Create.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,44 @@
import { checkIfTypeIsString, checkRequestBodyParamsForCreateOrUpdate } from "../../../_helpers/RequestParamsHelper";
import { checkIfRequestBodyExists, checkIfTypeIsString } from "../../../_common/utils/Request.utils";

import Credential from '../../../_common/models/Credential.model';
import { HttpRequest } from "@azure/functions";
import { Password } from '../../models/Password';
import { checkFetchingRequestBodyParamsForCreateOrUpdate } from "../../../_common/utils/FetchingRequest.utils";
import { throwIfDatabaseResourceExists } from "../../../_common/utils/DatabaseResponse.utils";

export const create = async (req: HttpRequest) => {
const { id_connection, password } = req.body;
// Check if request body exists
checkIfRequestBodyExists(req.body);

try {
// Chack body params
checkRequestBodyParamsForCreateOrUpdate(id_connection, password);
const { id_connection, password } = req.body;

// Check connection
checkIfTypeIsString(id_connection, 'id_connection');
// Chack body params
checkFetchingRequestBodyParamsForCreateOrUpdate(id_connection, password);

// Check password
checkIfTypeIsString(password, 'password');
// Check connection
checkIfTypeIsString(id_connection, 'id_connection');

// Check if row with id_connection already exists
const response_from_db = await Credential.get(id_connection);
// Check password
checkIfTypeIsString(password, 'password');

if (response_from_db) {
return {
status: 409,
body: {
status: 'Fail',
description: 'Resource with the provided id_connection already exists.'
}
};
}
// Check if row with id_connection already exists
const response_from_db = await Credential.get(id_connection);

const encrypt_password = Password.encryptPassword(password);
// If exists throw error 409 - Conflict
throwIfDatabaseResourceExists(response_from_db, 'id_connection');

await Credential.create(encrypt_password, id_connection);
}
catch (error) {
if (error.status) {
return error;
}
const encrypt_password = Password.encryptPassword(password);

return {
status: 500,
body: {
status: 'Error',
description: 'An unexpected error occurred. Please try again later.'
}
};
}
await Credential.create(encrypt_password, id_connection);

return {
status: 201,
body: {
status: 'OK',
status: 'Created',
description: 'New resource created successfully.'
},
headers: {
'Content-Type': 'application/json'
}
};
}
56 changes: 18 additions & 38 deletions Credentials/controllers/fetching/Get.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,30 @@
import { checkIfTypeIsString, checkRequestQueryParamsForGetOrRemove } from "../../../_helpers/RequestParamsHelper";
import { checkIfTypeIsString } from "../../../_common/utils/Request.utils";
import { checkFetchingRequestQueryParamsForGetOrDelete } from "../../../_common/utils/FetchingRequest.utils";

import Credential from '../../../_common/models/Credential.model';
import { HttpRequest } from "@azure/functions";
import { throwIfDatabaseResourceNotExists } from "../../../_common/utils/DatabaseResponse.utils";

export const get = async (req: HttpRequest) => {
const { id_connection } = req.query;

try {
// Chack body params
checkRequestQueryParamsForGetOrRemove(id_connection);
// Chack body params
checkFetchingRequestQueryParamsForGetOrDelete(id_connection);

// Check connection
checkIfTypeIsString(id_connection, 'id_connection');
// Check connection
checkIfTypeIsString(id_connection, 'id_connection');

// Check if row with id_connection already exists
const response_from_db = await Credential.get(id_connection);
// Check if row with id_connection already exists
const response_from_db = await Credential.get(id_connection);

if (!response_from_db) {
return {
status: 404,
body: {
status: 'Fail',
description: 'Resource with the provided id_connection not exists.'
}
};
}
// If not exists throw error 404 - Not found
throwIfDatabaseResourceNotExists(response_from_db, 'id_connection');

return {
status: 200,
body: {
status: 'OK',
payload: response_from_db
}
};
}
catch (error) {
if (error.status) {
return error;
return {
status: 200,
body: {
status: 'OK',
payload: response_from_db
}

return {
status: 500,
body: {
status: 'Error',
description: 'An unexpected error occurred. Please try again later.'
}
};
}
}
};
}
47 changes: 15 additions & 32 deletions Credentials/controllers/fetching/Remove.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,29 @@
import { checkIfTypeIsString, checkRequestQueryParamsForGetOrRemove } from "../../../_helpers/RequestParamsHelper";
import { checkIfRequestBodyExists, checkIfTypeIsString } from "../../../_common/utils/Request.utils";
import { checkFetchingRequestBodyParamsForDelete } from "../../../_common/utils/FetchingRequest.utils";

import Credential from '../../../_common/models/Credential.model';
import { HttpRequest } from "@azure/functions";
import { throwIfDatabaseResourceNotExists } from "../../../_common/utils/DatabaseResponse.utils";

export const remove = async (req: HttpRequest) => {
const { id_connection } = req.body;
// Check if request body exists
checkIfRequestBodyExists(req.body);

try {
// Chack body params
checkRequestQueryParamsForGetOrRemove(id_connection);
const { id_connection } = req.body;

// Check connection
checkIfTypeIsString(id_connection, 'id_connection');
// Chack body params
checkFetchingRequestBodyParamsForDelete(id_connection);

// Check if row with id_connection already exists
let response_from_db = await Credential.get(id_connection.toString());
// Check connection
checkIfTypeIsString(id_connection, 'id_connection');

if (!response_from_db) {
return {
status: 404,
body: {
status: 'Fail',
description: 'Resource with the provided id_connection does not exist.'
}
};
}
// Check if row with id_connection already exists
let response_from_db = await Credential.get(id_connection.toString());

await Credential.delete(response_from_db);
}
catch (error) {
if (error.status) {
return error;
}
// If not exists throw error 404 - Not found
throwIfDatabaseResourceNotExists(response_from_db, 'id_connection');

return {
status: 500,
body: {
status: 'Error',
description: 'An unexpected error occurred. Please try again later.'
}
};
}
await Credential.delete(response_from_db);

return {
status: 200,
Expand Down
61 changes: 21 additions & 40 deletions Credentials/controllers/fetching/Update.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,39 @@
import { checkIfTypeIsString, checkRequestBodyParamsForCreateOrUpdate } from "../../../_helpers/RequestParamsHelper";
import { checkIfRequestBodyExists, checkIfTypeIsString } from "../../../_common/utils/Request.utils";
import { checkFetchingRequestBodyParamsForCreateOrUpdate } from "../../../_common/utils/FetchingRequest.utils";

import Credential from '../../../_common/models/Credential.model';
import { HttpRequest } from "@azure/functions";
import { Password } from "../../models/Password";
import { throwIfDatabaseResourceNotExists } from "../../../_common/utils/DatabaseResponse.utils";

export const update = async (req: HttpRequest) => {
// Check if request body exists
checkIfRequestBodyExists(req.body);

const { id_connection, password } = req.body;

try {
// Chack body params
checkRequestBodyParamsForCreateOrUpdate(id_connection, password);
// Chack body params
checkFetchingRequestBodyParamsForCreateOrUpdate(id_connection, password);

// Check connection
checkIfTypeIsString(id_connection, 'id_connection');
// Check connection
checkIfTypeIsString(id_connection, 'id_connection');

// Check password
checkIfTypeIsString(password, 'password');
// Check password
checkIfTypeIsString(password, 'password');

const encrypt_password = Password.encryptPassword(password);
const encrypt_password = Password.encryptPassword(password);

// Check if row with id_connection already exists
let response_from_db = await Credential.get(id_connection.toString());
// Check if row with id_connection already exists
let response_from_db = await Credential.get(id_connection.toString());

// If not exist create
if (!response_from_db) {
return {
status: 404,
body: {
status: 'Fail',
description: 'Resource with the provided ID Credential does not exist.'
}
};
}
else {
// Update object properties
response_from_db.password = encrypt_password;
response_from_db.updated_at = new Date().toISOString();
// If not exists throw error 404 - Not found
throwIfDatabaseResourceNotExists(response_from_db, 'id_connection');

await Credential.update(response_from_db);
}
}
catch (error) {
if (error.status) {
return error;
}
// Update object properties
response_from_db.password = encrypt_password;
response_from_db.updated_at = new Date().toISOString();

return {
status: 500,
body: {
status: 'Error',
description: 'An unexpected error occurred. Please try again later.'
}
};
}
await Credential.update(response_from_db);

return {
status: 200,
Expand Down
53 changes: 53 additions & 0 deletions Credentials/controllers/receiving/Create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { checkIfPositiveIntegerNumber, checkIfRequestBodyExists, checkIfTypeIsString } from "../../../_common/utils/Request.utils";

import { HttpRequest } from "@azure/functions";
import ReceivingCredential from '../../../_common/models/ReceivingCredential.model';
import { checkReceivingRequestBodyParamsForCreateOrUpdate } from '../../../_common/utils/ReceivingRequest.utils';
import { throwIfDatabaseResourceExists } from "../../../_common/utils/DatabaseResponse.utils";

export const createReceive = async (req: HttpRequest) => {
// Check if request body exists
checkIfRequestBodyExists(req.body);

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

// Chack body params
checkReceivingRequestBodyParamsForCreateOrUpdate(uuid, username, id_account);

checkIfPositiveIntegerNumber(id_account, 'id_account');

checkIfTypeIsString(uuid, 'uuid');

checkIfTypeIsString(username, 'username');

// Check if row with id_account already exists
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');

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

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

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

return {
status: 201,
body: {
status: 'Created',
description: 'New resource created successfully.'
},
headers: {
'Content-Type': 'application/json'
}
};
}
Loading
Loading