feat: Convert all app files to JS
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
const addAuthHeader = ($, requestConfig) => {
|
||||
if (requestConfig.additionalProperties?.skipAddingAuthHeader)
|
||||
return requestConfig;
|
||||
|
@@ -0,0 +1,16 @@
|
||||
import isObject from 'lodash/isObject.js';
|
||||
|
||||
export function filterProvidedFields(body) {
|
||||
return Object.keys(body).reduce((result, key) => {
|
||||
const value = body[key];
|
||||
if (isObject(value)) {
|
||||
const filteredNestedObj = filterProvidedFields(value);
|
||||
if (Object.keys(filteredNestedObj).length > 0) {
|
||||
result[key] = filteredNestedObj;
|
||||
}
|
||||
} else if (body[key]) {
|
||||
result[key] = value;
|
||||
}
|
||||
return result;
|
||||
}, {});
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
import isObject from 'lodash/isObject';
|
||||
|
||||
export function filterProvidedFields(body: Record<string, unknown>) {
|
||||
return Object.keys(body).reduce<Record<string, unknown>>((result, key) => {
|
||||
const value = body[key];
|
||||
if (isObject(value)) {
|
||||
const filteredNestedObj = filterProvidedFields(
|
||||
value as Record<string, unknown>
|
||||
);
|
||||
if (Object.keys(filteredNestedObj).length > 0) {
|
||||
result[key] = filteredNestedObj;
|
||||
}
|
||||
} else if (body[key]) {
|
||||
result[key] = value;
|
||||
}
|
||||
return result;
|
||||
}, {});
|
||||
}
|
@@ -1,6 +1,4 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
const getCurrentUser = async ($: IGlobalVariable): Promise<IJSONObject> => {
|
||||
const getCurrentUser = async ($) => {
|
||||
const response = await $.http.get(`${$.auth.data.apiDomain}/api/v1/users/me`);
|
||||
const currentUser = response.data.data;
|
||||
|
10
packages/backend/src/apps/pipedrive/common/set-base-url.js
Normal file
10
packages/backend/src/apps/pipedrive/common/set-base-url.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const setBaseUrl = ($, requestConfig) => {
|
||||
const { apiDomain } = $.auth.data;
|
||||
|
||||
if (apiDomain) {
|
||||
requestConfig.baseURL = apiDomain;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
export default setBaseUrl;
|
@@ -1,12 +0,0 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const setBaseUrl: TBeforeRequest = ($, requestConfig) => {
|
||||
const { apiDomain } = $.auth.data;
|
||||
|
||||
if (apiDomain) {
|
||||
requestConfig.baseURL = apiDomain as string;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
export default setBaseUrl;
|
Reference in New Issue
Block a user