feat: Convert all app files to JS
This commit is contained in:
15
packages/backend/src/apps/todoist/auth/generate-auth-url.js
Normal file
15
packages/backend/src/apps/todoist/auth/generate-auth-url.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import { URLSearchParams } from 'url';
|
||||
|
||||
export default async function generateAuthUrl($) {
|
||||
const scopes = ['data:read_write'];
|
||||
const searchParams = new URLSearchParams({
|
||||
client_id: $.auth.data.clientId,
|
||||
scope: scopes.join(','),
|
||||
});
|
||||
|
||||
const url = `${$.app.baseUrl}/oauth/authorize?${searchParams.toString()}`;
|
||||
|
||||
await $.auth.set({
|
||||
url,
|
||||
});
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import { URLSearchParams } from 'url';
|
||||
|
||||
export default async function generateAuthUrl($: IGlobalVariable) {
|
||||
const scopes = ['data:read_write'];
|
||||
const searchParams = new URLSearchParams({
|
||||
client_id: $.auth.data.clientId as string,
|
||||
scope: scopes.join(','),
|
||||
});
|
||||
|
||||
const url = `${$.app.baseUrl
|
||||
}/oauth/authorize?${searchParams.toString()}`;
|
||||
|
||||
await $.auth.set({
|
||||
url,
|
||||
});
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
import generateAuthUrl from './generate-auth-url';
|
||||
import verifyCredentials from './verify-credentials';
|
||||
import isStillVerified from './is-still-verified';
|
||||
import generateAuthUrl from './generate-auth-url.js';
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
import isStillVerified from './is-still-verified.js';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'oAuthRedirectUrl',
|
||||
label: 'OAuth Redirect URL',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: true,
|
||||
value: '{WEB_APP_URL}/app/todoist/connections/add',
|
||||
@@ -20,7 +20,7 @@ export default {
|
||||
{
|
||||
key: 'screenName',
|
||||
label: 'Screen Name',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -31,7 +31,7 @@ export default {
|
||||
{
|
||||
key: 'clientId',
|
||||
label: 'Client ID',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -42,7 +42,7 @@ export default {
|
||||
{
|
||||
key: 'clientSecret',
|
||||
label: 'Client Secret',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -0,0 +1,6 @@
|
||||
const isStillVerified = async ($) => {
|
||||
await $.http.get('/projects');
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
||||
@@ -1,8 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
await $.http.get('/projects');
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
||||
14
packages/backend/src/apps/todoist/auth/verify-credentials.js
Normal file
14
packages/backend/src/apps/todoist/auth/verify-credentials.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const verifyCredentials = async ($) => {
|
||||
const { data } = await $.http.post(`${$.app.baseUrl}/oauth/access_token`, {
|
||||
client_id: $.auth.data.clientId,
|
||||
client_secret: $.auth.data.clientSecret,
|
||||
code: $.auth.data.code,
|
||||
});
|
||||
|
||||
await $.auth.set({
|
||||
tokenType: data.token_type,
|
||||
accessToken: data.access_token,
|
||||
});
|
||||
};
|
||||
|
||||
export default verifyCredentials;
|
||||
@@ -1,19 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
const { data } = await $.http.post(
|
||||
`${$.app.baseUrl}/oauth/access_token`,
|
||||
{
|
||||
client_id: $.auth.data.clientId,
|
||||
client_secret: $.auth.data.clientSecret,
|
||||
code: $.auth.data.code,
|
||||
},
|
||||
);
|
||||
|
||||
await $.auth.set({
|
||||
tokenType: data.token_type,
|
||||
accessToken: data.access_token,
|
||||
});
|
||||
};
|
||||
|
||||
export default verifyCredentials;
|
||||
Reference in New Issue
Block a user