feat: add defineApp and beforeRequest

This commit is contained in:
Ali BARIN
2022-10-17 23:29:20 +02:00
parent 314787f39c
commit 1760c6e454
7 changed files with 60 additions and 21 deletions

View File

@@ -0,0 +1,11 @@
import { TBeforeRequest } from "@automatisch/types";
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
if (requestConfig.headers && $.auth.data?.accessToken) {
requestConfig.headers.Authorization = `Bearer ${$.auth.data.accessToken}`
}
return requestConfig;
}
export default addAuthHeader;

View File

@@ -1,4 +1,7 @@
export default {
import defineApp from '../../helpers/define-app';
import addAuthHeader from './common/add-auth-header';
export default defineApp({
name: 'Github',
key: 'github',
baseUrl: 'https://github.com',
@@ -7,4 +10,5 @@ export default {
authDocUrl: 'https://automatisch.io/docs/connections/github',
primaryColor: '000000',
supportsConnections: true,
};
beforeRequest: [addAuthHeader],
});