Throw if the clients are passed an undefined apikey or token
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
---
|
||||
"@trigger.dev/typeform": patch
|
||||
"@trigger.dev/github": patch
|
||||
"@trigger.dev/openai": patch
|
||||
"@trigger.dev/resend": patch
|
||||
"@trigger.dev/plain": patch
|
||||
---
|
||||
|
||||
Throw if the clients are passed an undefined apikey or token
|
||||
@@ -92,6 +92,10 @@ export class Github
|
||||
function createClientFromOptions(
|
||||
options: GithubIntegrationOptions
|
||||
): IntegrationClient<Octokit, typeof tasks> {
|
||||
if (Object.keys(options).includes("token") && !options.token) {
|
||||
throw new Error(`GitHub integration (${options.id}) token was undefined`);
|
||||
}
|
||||
|
||||
if (options.token) {
|
||||
const client = new Octokit({
|
||||
auth: options.token,
|
||||
|
||||
@@ -9,6 +9,12 @@ export class OpenAI
|
||||
client: IntegrationClient<OpenAIApi, typeof tasks>;
|
||||
|
||||
constructor(private options: OpenAIIntegrationOptions) {
|
||||
if (Object.keys(options).includes("apiKey") && !options.apiKey) {
|
||||
throw new Error(
|
||||
`OpenAI integration (${options.id}) apiKey was undefined`
|
||||
);
|
||||
}
|
||||
|
||||
this.client = {
|
||||
tasks,
|
||||
usesLocalAuth: true,
|
||||
|
||||
@@ -17,6 +17,10 @@ export class Plain implements PlainIntegration {
|
||||
client: PlainIntegrationClient;
|
||||
|
||||
constructor(private options: PlainIntegrationOptions) {
|
||||
if (Object.keys(options).includes("apiKey") && !options.apiKey) {
|
||||
throw new Error(`Plain integration (${options.id}) apiKey was undefined`);
|
||||
}
|
||||
|
||||
this.client = {
|
||||
tasks,
|
||||
usesLocalAuth: true,
|
||||
|
||||
@@ -56,6 +56,12 @@ export class Resend
|
||||
client: IntegrationClient<ResendClient, typeof tasks>;
|
||||
|
||||
constructor(private options: ResendIntegrationOptions) {
|
||||
if (Object.keys(options).includes("apiKey") && !options.apiKey) {
|
||||
throw new Error(
|
||||
`Resend integration (${options.id}) apiKey was undefined`
|
||||
);
|
||||
}
|
||||
|
||||
this.client = {
|
||||
tasks,
|
||||
usesLocalAuth: true,
|
||||
|
||||
@@ -34,6 +34,12 @@ export class Typeform implements TypeformIntegration {
|
||||
client: TypeformIntegrationClient;
|
||||
|
||||
constructor(private options: TypeformIntegrationOptions) {
|
||||
if (Object.keys(options).includes("token") && !options.token) {
|
||||
throw new Error(
|
||||
`Typeform integration (${options.id}) token was undefined`
|
||||
);
|
||||
}
|
||||
|
||||
this.client = {
|
||||
tasks,
|
||||
usesLocalAuth: true,
|
||||
|
||||
Reference in New Issue
Block a user