Skip to content

Commit

Permalink
chore: exiting if variable env is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Burtey committed Jul 16, 2023
1 parent 77fcaee commit 6e4fd09
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions e2e/utils/email.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import axios from "axios"

export const mailslurpApiKey = process.env.MAILSLURP_API_KEY || ""
export const mailslurpApiKey = process.env.MAILSLURP_API_KEY
if (mailslurpApiKey === undefined) {
console.error("-----------------------------")
console.error("MAILSLURP_API_KEY not set")
console.error("-----------------------------")
process.exit(1)
}

const headers = {
"Accept": "application/json",
Expand All @@ -10,8 +16,7 @@ const headers = {
export const getInbox = async () => {
const optionsCreateInbox = {
method: "POST",
url: `https://api.mailslurp.com/inboxes?useShortAddress=true`,
// url: `https://api.mailslurp.com/inboxes?expiresIn=60000&useShortAddress=true`,
url: `https://api.mailslurp.com/inboxes?expiresIn=60000&useShortAddress=true`,
headers,
}

Expand All @@ -25,10 +30,10 @@ export const getInbox = async () => {
}
}

export const getFirstEmail = async (inboxId: string) => {
const getEmail = async (inboxId: string, index: number) => {
const optionsGetEmails = {
method: "GET",
url: `https://api.mailslurp.com/waitForNthEmail?inboxId=${inboxId}&index=0&unreadOnly=false`,
url: `https://api.mailslurp.com/waitForNthEmail?inboxId=${inboxId}&index=${index}&unreadOnly=false`,
headers,
}

Expand All @@ -42,5 +47,12 @@ export const getFirstEmail = async (inboxId: string) => {
}
}

export const getFirstEmail = async (inboxId: string) => {
return getEmail(inboxId, 0)
}
export const getSecondEmail = async (inboxId: string) => {
return getEmail(inboxId, 1)
}

// getInbox()
// getFirstEmail("a96cfd50-4c3e-4a1e-ba48-b7aa7958363f")

0 comments on commit 6e4fd09

Please sign in to comment.