fix: Backend eslint warnings

This commit is contained in:
Faruk AYDIN
2022-03-07 16:18:29 +03:00
committed by Ömer Faruk Aydın
parent ecc9239bfe
commit 775ac7a8b1
20 changed files with 144 additions and 71 deletions

View File

@@ -1,17 +1,22 @@
import type { IField } from '@automatisch/types'; import type {
IAuthentication,
IApp,
IField,
IJSONObject,
} from '@automatisch/types';
import { URLSearchParams } from 'url'; import { URLSearchParams } from 'url';
import axios, { AxiosInstance } from 'axios'; import axios, { AxiosInstance } from 'axios';
export default class Authentication { export default class Authentication implements IAuthentication {
appData: any; appData: IApp;
connectionData: any; connectionData: IJSONObject;
client: AxiosInstance = axios.create({ client: AxiosInstance = axios.create({
baseURL: 'https://discord.com/api/', baseURL: 'https://discord.com/api/',
}); });
scope: string[] = ['identify', 'email']; scope: string[] = ['identify', 'email'];
constructor(appData: any, connectionData: any) { constructor(appData: IApp, connectionData: IJSONObject) {
this.appData = appData; this.appData = appData;
this.connectionData = connectionData; this.connectionData = connectionData;
} }
@@ -24,7 +29,7 @@ export default class Authentication {
async createAuthData() { async createAuthData() {
const searchParams = new URLSearchParams({ const searchParams = new URLSearchParams({
client_id: this.connectionData.consumerKey, client_id: this.connectionData.consumerKey as string,
redirect_uri: this.oauthRedirectUrl, redirect_uri: this.oauthRedirectUrl,
response_type: 'code', response_type: 'code',
scope: this.scope.join(' '), scope: this.scope.join(' '),
@@ -37,15 +42,15 @@ export default class Authentication {
async verifyCredentials() { async verifyCredentials() {
const params = new URLSearchParams({ const params = new URLSearchParams({
client_id: this.connectionData.consumerKey, client_id: this.connectionData.consumerKey as string,
redirect_uri: this.oauthRedirectUrl, redirect_uri: this.oauthRedirectUrl,
response_type: 'code', response_type: 'code',
scope: this.scope.join(' '), scope: this.scope.join(' '),
client_secret: this.connectionData.consumerSecret, client_secret: this.connectionData.consumerSecret as string,
code: this.connectionData.oauthVerifier, code: this.connectionData.oauthVerifier as string,
grant_type: 'authorization_code', grant_type: 'authorization_code',
}); });
const { data: verifiedCredentials }: any = await this.client.post( const { data: verifiedCredentials } = await this.client.post(
'/oauth2/token', '/oauth2/token',
params.toString() params.toString()
); );
@@ -58,7 +63,7 @@ export default class Authentication {
token_type: tokenType, token_type: tokenType,
} = verifiedCredentials; } = verifiedCredentials;
const { data: user }: any = await this.client.get('/users/@me', { const { data: user } = await this.client.get('/users/@me', {
headers: { headers: {
Authorization: `${tokenType} ${accessToken}`, Authorization: `${tokenType} ${accessToken}`,
}, },

View File

@@ -1,9 +1,15 @@
import Authentication from './authentication'; import Authentication from './authentication';
import {
IService,
IAuthentication,
IApp,
IJSONObject,
} from '@automatisch/types';
export default class Discord { export default class Discord implements IService {
authenticationClient: any; authenticationClient: IAuthentication;
constructor(appData: any, connectionData: any) { constructor(appData: IApp, connectionData: IJSONObject) {
this.authenticationClient = new Authentication(appData, connectionData); this.authenticationClient = new Authentication(appData, connectionData);
} }
} }

View File

@@ -1,9 +1,15 @@
import Authentication from './authentication'; import Authentication from './authentication';
import {
IService,
IAuthentication,
IApp,
IJSONObject,
} from '@automatisch/types';
export default class Firebase { export default class Firebase implements IService {
authenticationClient: any; authenticationClient: IAuthentication;
constructor(appData: any, connectionData: any) { constructor(appData: IApp, connectionData: IJSONObject) {
this.authenticationClient = new Authentication(appData, connectionData); this.authenticationClient = new Authentication(appData, connectionData);
} }
} }

View File

@@ -1,9 +1,15 @@
import Authentication from './authentication'; import Authentication from './authentication';
import {
IService,
IAuthentication,
IApp,
IJSONObject,
} from '@automatisch/types';
export default class Flickr { export default class Flickr implements IService {
authenticationClient: any; authenticationClient: IAuthentication;
constructor(appData: any, connectionData: any) { constructor(appData: IApp, connectionData: IJSONObject) {
this.authenticationClient = new Authentication(appData, connectionData); this.authenticationClient = new Authentication(appData, connectionData);
} }
} }

View File

@@ -1,9 +1,15 @@
import Authentication from './authentication'; import Authentication from './authentication';
import {
IService,
IAuthentication,
IApp,
IJSONObject,
} from '@automatisch/types';
export default class Github { export default class Github implements IService {
authenticationClient: any; authenticationClient: IAuthentication;
constructor(appData: any, connectionData: any) { constructor(appData: IApp, connectionData: IJSONObject) {
this.authenticationClient = new Authentication(appData, connectionData); this.authenticationClient = new Authentication(appData, connectionData);
} }
} }

View File

@@ -1,9 +1,4 @@
import type { import type { IAuthentication, IApp, IJSONObject } from '@automatisch/types';
IAuthentication,
IApp,
IField,
IJSONObject,
} from '@automatisch/types';
import { Client } from 'pg'; import { Client } from 'pg';
export default class Authentication implements IAuthentication { export default class Authentication implements IAuthentication {

View File

@@ -1,9 +1,15 @@
import Authentication from './authentication'; import Authentication from './authentication';
import {
IService,
IAuthentication,
IApp,
IJSONObject,
} from '@automatisch/types';
export default class PostgreSQL { export default class PostgreSQL implements IService {
authenticationClient: any; authenticationClient: IAuthentication;
constructor(appData: any, connectionData: any) { constructor(appData: IApp, connectionData: IJSONObject) {
this.authenticationClient = new Authentication(appData, connectionData); this.authenticationClient = new Authentication(appData, connectionData);
} }
} }

View File

@@ -1,9 +1,15 @@
import Authentication from './authentication'; import Authentication from './authentication';
import {
IService,
IAuthentication,
IApp,
IJSONObject,
} from '@automatisch/types';
export default class SMTP { export default class SMTP implements IService {
authenticationClient: any; authenticationClient: IAuthentication;
constructor(appData: any, connectionData: any) { constructor(appData: IApp, connectionData: IJSONObject) {
this.authenticationClient = new Authentication(appData, connectionData); this.authenticationClient = new Authentication(appData, connectionData);
} }
} }

View File

@@ -1,9 +1,15 @@
import Authentication from './authentication'; import Authentication from './authentication';
import {
IService,
IAuthentication,
IApp,
IJSONObject,
} from '@automatisch/types';
export default class Twilio { export default class Twilio implements IService {
authenticationClient: any; authenticationClient: IAuthentication;
constructor(appData: any, connectionData: any) { constructor(appData: IApp, connectionData: IJSONObject) {
this.authenticationClient = new Authentication(appData, connectionData); this.authenticationClient = new Authentication(appData, connectionData);
} }
} }

View File

@@ -1,9 +1,15 @@
import Authentication from './authentication'; import Authentication from './authentication';
import {
IService,
IAuthentication,
IApp,
IJSONObject,
} from '@automatisch/types';
export default class Twitch { export default class Twitch implements IService {
authenticationClient: any; authenticationClient: IAuthentication;
constructor(appData: any, connectionData: any) { constructor(appData: IApp, connectionData: IJSONObject) {
this.authenticationClient = new Authentication(appData, connectionData); this.authenticationClient = new Authentication(appData, connectionData);
} }
} }

View File

@@ -1,9 +1,10 @@
import CreateTweet from './actions/create-tweet'; import CreateTweet from './actions/create-tweet';
import { IJSONObject } from '@automatisch/types';
export default class Actions { export default class Actions {
createTweet: any createTweet: CreateTweet;
constructor(connectionData: any, parameters: any) { constructor(connectionData: IJSONObject, parameters: IJSONObject) {
this.createTweet = new CreateTweet(connectionData, parameters) this.createTweet = new CreateTweet(connectionData, parameters);
} }
} }

View File

@@ -1,22 +1,23 @@
import TwitterApi from 'twitter-api-v2'; import TwitterApi, { TwitterApiTokens } from 'twitter-api-v2';
import { IJSONObject } from '@automatisch/types';
export default class CreateTweet { export default class CreateTweet {
client: any; client: TwitterApi;
parameters: any; parameters: IJSONObject;
constructor(connectionData: any, parameters: any) { constructor(connectionData: IJSONObject, parameters: IJSONObject) {
this.client = new TwitterApi({ this.client = new TwitterApi({
appKey: connectionData.consumerKey, appKey: connectionData.consumerKey,
appSecret: connectionData.consumerSecret, appSecret: connectionData.consumerSecret,
accessToken: connectionData.accessToken, accessToken: connectionData.accessToken,
accessSecret: connectionData.accessSecret, accessSecret: connectionData.accessSecret,
}); } as TwitterApiTokens);
this.parameters = parameters; this.parameters = parameters;
} }
async run() { async run() {
const tweet = await this.client.v1.tweet(this.parameters.tweet); const tweet = await this.client.v1.tweet(this.parameters.tweet as string);
return tweet; return tweet;
} }
} }

View File

@@ -1,13 +1,23 @@
import {
IService,
IAuthentication,
IApp,
IJSONObject,
} from '@automatisch/types';
import Authentication from './authentication'; import Authentication from './authentication';
import Triggers from './triggers'; import Triggers from './triggers';
import Actions from './actions'; import Actions from './actions';
export default class Twitter { export default class Twitter implements IService {
authenticationClient: any; authenticationClient: IAuthentication;
triggers: any; triggers: Triggers;
actions: any; actions: Actions;
constructor(appData: any, connectionData: any, parameters: any) { constructor(
appData: IApp,
connectionData: IJSONObject,
parameters: IJSONObject
) {
this.authenticationClient = new Authentication(appData, connectionData); this.authenticationClient = new Authentication(appData, connectionData);
this.triggers = new Triggers(connectionData); this.triggers = new Triggers(connectionData);
this.actions = new Actions(connectionData, parameters); this.actions = new Actions(connectionData, parameters);

View File

@@ -1,9 +1,10 @@
import MyTweet from './triggers/my-tweet'; import MyTweet from './triggers/my-tweet';
import { IJSONObject } from '@automatisch/types';
export default class Triggers { export default class Triggers {
myTweet: any myTweet: MyTweet;
constructor(connectionData: any) { constructor(connectionData: IJSONObject) {
this.myTweet = new MyTweet(connectionData) this.myTweet = new MyTweet(connectionData);
} }
} }

View File

@@ -1,15 +1,16 @@
import TwitterApi from 'twitter-api-v2'; import TwitterApi, { TwitterApiTokens } from 'twitter-api-v2';
import { IJSONObject } from '@automatisch/types';
export default class MyTweet { export default class MyTweet {
client: any client: TwitterApi;
constructor(connectionData: any) { constructor(connectionData: IJSONObject) {
this.client = new TwitterApi({ this.client = new TwitterApi({
appKey: connectionData.consumerKey, appKey: connectionData.consumerKey,
appSecret: connectionData.consumerSecret, appSecret: connectionData.consumerSecret,
accessToken: connectionData.accessToken, accessToken: connectionData.accessToken,
accessSecret: connectionData.accessSecret accessSecret: connectionData.accessSecret,
}); } as TwitterApiTokens);
} }
async run() { async run() {

View File

@@ -56,7 +56,7 @@ export default class Authentication implements IAuthentication {
redirect_uri: this.oauthRedirectUrl, redirect_uri: this.oauthRedirectUrl,
}); });
const { data: verifiedCredentials }: any = await this.client.post( const { data: verifiedCredentials } = await this.client.post(
'/oauth/token', '/oauth/token',
params.toString() params.toString()
); );
@@ -67,7 +67,7 @@ export default class Authentication implements IAuthentication {
token_type: tokenType, token_type: tokenType,
} = verifiedCredentials; } = verifiedCredentials;
const { data: user }: any = await this.client.get('/me', { const { data: user } = await this.client.get('/me', {
headers: { headers: {
Authorization: `Bearer ${accessToken}`, Authorization: `Bearer ${accessToken}`,
}, },

View File

@@ -1,9 +1,15 @@
import Authentication from './authentication'; import Authentication from './authentication';
import {
IService,
IAuthentication,
IApp,
IJSONObject,
} from '@automatisch/types';
export default class Typeform { export default class Typeform implements IService {
authenticationClient: any; authenticationClient: IAuthentication;
constructor(appData: any, connectionData: any) { constructor(appData: IApp, connectionData: IJSONObject) {
this.authenticationClient = new Authentication(appData, connectionData); this.authenticationClient = new Authentication(appData, connectionData);
} }
} }

View File

@@ -1,5 +1,6 @@
import Context from '../../types/express/context'; import Context from '../../types/express/context';
import Processor from '../../services/processor'; import Processor from '../../services/processor';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import processorQueue from '../../queues/processor'; import processorQueue from '../../queues/processor';
type Params = { type Params = {

View File

@@ -6,8 +6,8 @@ class ExecutionStep extends Base {
id!: string; id!: string;
executionId!: string; executionId!: string;
stepId!: string; stepId!: string;
dataIn!: any; dataIn!: Record<string, unknown>;
dataOut!: any; dataOut!: Record<string, unknown>;
status: string; status: string;
static tableName = 'execution_steps'; static tableName = 'execution_steps';

View File

@@ -114,11 +114,15 @@ export interface IApp {
connections: IConnection[]; connections: IConnection[];
} }
export interface IService {
authenticationClient: IAuthentication;
}
export interface IAuthentication { export interface IAuthentication {
appData: IApp; appData: IApp;
connectionData: IJSONObject; connectionData: IJSONObject;
client: unknown; client: unknown;
verifyCredentials(): Promise<JSONObject>; verifyCredentials(): Promise<IJSONObject>;
isStillVerified(): Promise<boolean>; isStillVerified(): Promise<boolean>;
} }