feat(notion): add auth and new DB items trigger

This commit is contained in:
Ali BARIN
2023-06-12 22:45:37 +00:00
parent f2dc2f5530
commit 6be8b55daa
15 changed files with 351 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import { IField, IGlobalVariable } from '@automatisch/types';
import { URL, URLSearchParams } from 'url';
export default async function generateAuthUrl($: IGlobalVariable) {
const oauthRedirectUrlField = $.app.auth.fields.find(
(field: IField) => field.key == 'oAuthRedirectUrl'
);
const redirectUri = oauthRedirectUrlField.value as string;
const searchParams = new URLSearchParams({
client_id: $.auth.data.clientId as string,
redirect_uri: redirectUri,
response_type: 'code',
owner: 'user',
});
const url = new URL(`/v1/oauth/authorize?${searchParams}`, $.app.apiBaseUrl).toString();
await $.auth.set({
url,
});
}