test: make better stack first when creating a connection

This commit is contained in:
Rıdvan Akca
2023-12-11 13:58:27 +03:00
parent e5c4e18fd5
commit 8a8be21d56
7 changed files with 17 additions and 22 deletions

View File

@@ -1,12 +1,12 @@
import verifyCredentials from './verify-credentials'; import verifyCredentials from './verify-credentials.js';
import isStillVerified from './is-still-verified'; import isStillVerified from './is-still-verified.js';
export default { export default {
fields: [ fields: [
{ {
key: 'screenName', key: 'screenName',
label: 'Screen Name', label: 'Screen Name',
type: 'string' as const, type: 'string',
required: true, required: true,
readOnly: false, readOnly: false,
value: null, value: null,
@@ -18,7 +18,7 @@ export default {
{ {
key: 'apiKey', key: 'apiKey',
label: 'API Key', label: 'API Key',
type: 'string' as const, type: 'string',
required: true, required: true,
readOnly: false, readOnly: false,
value: null, value: null,

View File

@@ -0,0 +1,8 @@
import verifyCredentials from './verify-credentials.js';
const isStillVerified = async ($) => {
await verifyCredentials($);
return true;
};
export default isStillVerified;

View File

@@ -1,9 +0,0 @@
import { IGlobalVariable } from '@automatisch/types';
import verifyCredentials from './verify-credentials';
const isStillVerified = async ($: IGlobalVariable) => {
await verifyCredentials($);
return true;
};
export default isStillVerified;

View File

@@ -1,6 +1,4 @@
import { IGlobalVariable } from '@automatisch/types'; const verifyCredentials = async ($) => {
const verifyCredentials = async ($: IGlobalVariable) => {
await $.http.get('/v2/metadata'); await $.http.get('/v2/metadata');
await $.auth.set({ await $.auth.set({

View File

@@ -1,6 +1,4 @@
import { TBeforeRequest } from '@automatisch/types'; const addAuthHeader = ($, requestConfig) => {
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
if ($.auth.data?.apiKey) { if ($.auth.data?.apiKey) {
requestConfig.headers.Authorization = `Bearer ${$.auth.data.apiKey}`; requestConfig.headers.Authorization = `Bearer ${$.auth.data.apiKey}`;
} }

View File

@@ -1,6 +1,6 @@
import defineApp from '../../helpers/define-app'; import defineApp from '../../helpers/define-app.js';
import addAuthHeader from './common/add-auth-header'; import addAuthHeader from './common/add-auth-header.js';
import auth from './auth'; import auth from './auth/index.js';
export default defineApp({ export default defineApp({
name: 'Better Stack', name: 'Better Stack',