Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Undefined process #281

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/resend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ import { Emails } from './emails/emails';
import { isResendErrorResponse } from './guards';
import { ErrorResponse } from './interfaces';

const baseUrl = process.env.RESEND_BASE_URL || 'https://api.resend.com';
const userAgent = process.env.RESEND_USER_AGENT || `resend-node:${version}`;
const defaultBaseUrl = 'https://api.resend.com';
const defaultUserAgent = `resend-node:${version}`;
const baseUrl =
typeof process !== 'undefined' && process.env
? process.env.RESEND_BASE_URL || defaultBaseUrl
: defaultBaseUrl;
const userAgent =
typeof process !== 'undefined' && process.env
? process.env.RESEND_USER_AGENT || defaultUserAgent
: defaultUserAgent;

export class Resend {
private readonly headers: Headers;
Expand All @@ -20,7 +28,9 @@ export class Resend {

constructor(readonly key?: string) {
if (!key) {
this.key = process.env.RESEND_API_KEY;
if (typeof process !== 'undefined' && process.env) {
this.key = process.env.RESEND_API_KEY;
}

if (!this.key) {
throw new Error(
Expand Down