Skip to content

Commit

Permalink
refactor: make setting hostname and token in getSession more concise …
Browse files Browse the repository at this point in the history
…token in
  • Loading branch information
ajyey committed May 23, 2023
1 parent 85da512 commit 9b38d36
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/lib/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ export const getSession = async (
token?: string,
hostname?: string
): Promise<any> => {
if (!hostname) {
hostname = process.env.JMAP_HOSTNAME || API_HOSTNAME;
}
if (!token) {
token = process.env.JMAP_TOKEN;
}
hostname = hostname || process.env.JMAP_HOSTNAME || API_HOSTNAME;

token = token || process.env.JMAP_TOKEN;

if (!token) {
return Promise.reject(
new Error(
'No auth token provided and JMAP_TOKEN environment variable is not set. Please provide a token.'
)
);
}

const authUrl = `https://${hostname}/jmap/session`;
const headers = {
'Content-Type': 'application/json',
Expand Down

0 comments on commit 9b38d36

Please sign in to comment.