Add endpoints to create and delete remote server (#4606)

* Build remote server

* Add getters

* Migrate to json inputs

* Use extendable type

* Use regex validation

* Remove acronymes

---------

Co-authored-by: Thomas Trompette <thomast@twenty.com>
This commit is contained in:
Thomas Trompette
2024-03-25 15:21:23 +01:00
committed by GitHub
parent e2af5b8628
commit 9e70f5b650
17 changed files with 496 additions and 3 deletions

View File

@ -0,0 +1,20 @@
const INPUT_REGEX = /^([A-Za-z0-9\-\_]+)$/;
export const validateObject = (input: object) => {
for (const [key, value] of Object.entries(input)) {
// Password are encrypted so we don't need to validate them
if (key === 'password') {
continue;
}
if (!INPUT_REGEX.test(value.toString())) {
throw new Error('Invalid remote server input');
}
}
};
export const validateString = (input: string) => {
if (!INPUT_REGEX.test(input)) {
throw new Error('Invalid remote server input');
}
};