Skip to content

Commit

Permalink
refactor(cmd-socketio-server): cmd-socketio-server Verifier test adju…
Browse files Browse the repository at this point in the history
…stments

Fix warnings triggered by the strict flag, format the code according to
cactus/.prettierrc.js, minor fixes (mostly in log writing), dependency
injection for VerifierAuthentication.verify.

Closes: hyperledger-cacti#1573
Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
  • Loading branch information
outSH authored and takeutak committed Nov 26, 2021
1 parent 3534783 commit a7bcbd2
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 75 deletions.
8 changes: 8 additions & 0 deletions packages/cactus-cmd-socketio-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
"copy-static-assets": "ts-node copyStaticAssets.ts",
"test": "jest"
},
"workspaces": {
"nohoist": [
"@types/socket.io",
"@types/socket.io-client"
]
},
"dependencies": {
"@types/node": "^14.0.24",
"body-parser": "^1.19.0",
Expand All @@ -33,6 +39,8 @@
"@types/jest": "^26.0.19",
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
"@types/socket.io": "^2.0.4",
"@types/socket.io-client": "^1.4.36",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ export class ConfigUtil {
* @return {object} Merged objects
*/
private static mergeObjects(target: object, source: object): object {
const isObject = (obj) =>
const isObject = (obj: unknown) =>
obj && typeof obj === "object" && !Array.isArray(obj);
const mergeObject = Object.assign({}, target);
if (isObject(target) && isObject(source)) {
for (const [sourceKey, sourceValue] of Object.entries(source)) {
const targetValue = target[sourceKey];
const targetValue = (target as { [key: string]: any })[sourceKey];
if (isObject(sourceValue) && target.hasOwnProperty(sourceKey)) {
mergeObject[sourceKey] = ConfigUtil.mergeObjects(
targetValue,
sourceValue
);
(mergeObject as { [key: string]: any })[sourceKey] =
ConfigUtil.mergeObjects(targetValue, sourceValue);
} else {
Object.assign(mergeObject, { [sourceKey]: sourceValue });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function makeApiInfoList(targetApiInfo: any): ApiInfo[] {
}

// store on socket
const socketArray = [];
const socketArray: any[] = [];

// Returns the index of socketArray as a return value
export function addSocket(socket: any): number {
Expand Down
Loading

0 comments on commit a7bcbd2

Please sign in to comment.