maestro connection with microservices - clients and modules

This commit is contained in:
rodrigo.zamboni
2022-03-18 10:16:27 -03:00
parent e15a680b9f
commit 1523c6b4d1
25 changed files with 1668 additions and 639 deletions
+64
View File
@@ -0,0 +1,64 @@
export const objectCamelToSnake = (object) => {
const objectKeys = Object.keys(object);
const objectValues = Object.values(object);
const newKeys = objectKeys.map((key) => {
return key
.split(/(?=[A-Z])/)
.join("_")
.toLowerCase();
});
objectKeys.forEach((key, index) => {
object[newKeys[index]] = object[key];
if (newKeys[index] !== objectKeys[index]) {
delete object[key];
}
});
objectValues.forEach((value) => {
if (typeof value === "object") {
objectCamelToSnake(value);
}
});
return object;
};
export const objectSnakeToCamel = (object) => {
const objectKeys = Object.keys(object);
const objectValues = Object.values(object);
const newKeys = objectKeys.map((key) => {
return key.replace(/([-_][a-z])/gi, ($1) => {
return $1.toUpperCase().replace("-", "").replace("_", "");
});
});
objectKeys.forEach((key, index) => {
object[newKeys[index]] = object[key];
if (newKeys[index] !== objectKeys[index]) {
delete object[key];
}
});
objectValues.forEach((value) => {
if (typeof value === "object") {
objectSnakeToCamel(value);
}
});
return object;
};
export const trSnakeToCamel = (object) =>{
const convertedParams = object.params.map((param)=>{
return objectSnakeToCamel(param)
})
object.params = convertedParams
return objectSnakeToCamel(object)
}