refactor: use functional app implementation

This commit is contained in:
Ali BARIN
2022-10-06 23:27:37 +02:00
committed by Faruk AYDIN
parent 89d7359060
commit e7b47f5c98
9 changed files with 72 additions and 50 deletions

View File

@@ -1,5 +1,7 @@
import { IJSONObject } from '@automatisch/types';
import Context from '../../types/express/context';
import App from '../../models/app';
import globalVariable from '../../helpers/global-variable';
type Params = {
stepId: string;
@@ -22,11 +24,11 @@ const getData = async (_parent: unknown, params: Params, context: Context) => {
if (!connection || !step.appKey) return null;
const AppClass = (await import(`../../apps/${step.appKey}`)).default;
const appInstance = new AppClass(connection, step.flow, step);
const app = await App.findOneByKey(step.appKey);
const $ = await globalVariable(connection, app, step.flow, step)
const command = appInstance.data[params.key];
const fetchedData = await command.run();
const command = app.data[params.key];
const fetchedData = await command.run($);
return fetchedData;
};