This commit is contained in:
parent
4fd40b1f9d
commit
630387f889
24
src/api.ts
24
src/api.ts
@ -17,18 +17,30 @@ export const main = (port: number) => {
|
|||||||
jobInsensitive.to.username = "****REDACTED****";
|
jobInsensitive.to.username = "****REDACTED****";
|
||||||
jobInsensitive.to.password = "****REDACTED****";
|
jobInsensitive.to.password = "****REDACTED****";
|
||||||
|
|
||||||
|
const uuid = crypto.randomUUID();
|
||||||
ConsoleLogger.log(
|
ConsoleLogger.log(
|
||||||
`Received email job: ${JSON.stringify(jobInsensitive)}`,
|
`[${uuid}] Received email job: ${JSON.stringify(jobInsensitive)}`,
|
||||||
)();
|
)();
|
||||||
|
|
||||||
const performEmailTest = perform(job)();
|
const performEmailTest = perform(job)();
|
||||||
return await performEmailTest
|
return performEmailTest
|
||||||
.then(() => {
|
.then((result) => {
|
||||||
|
if (result._tag === "Left") {
|
||||||
|
const error = result.left;
|
||||||
|
ConsoleLogger.log(
|
||||||
|
`[${uuid}] job failure due to ${error.message}`,
|
||||||
|
)();
|
||||||
|
return new Response(error.message, {
|
||||||
|
status: 400,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ConsoleLogger.log(`[${uuid}] success`)();
|
||||||
return Response.json({ success: true });
|
return Response.json({ success: true });
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((e) => {
|
||||||
return new Response(error.message, {
|
ConsoleLogger.log(`[${uuid}] internal failure due to ${e}`)();
|
||||||
status: 400,
|
return new Response(e.message, {
|
||||||
|
status: 500,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,9 @@ const findEmailUidInInbox: FindEmailUidInInbox = (
|
|||||||
TE.fold(
|
TE.fold(
|
||||||
(e) =>
|
(e) =>
|
||||||
pipe(
|
pipe(
|
||||||
TE.fromIO(ConsoleLogger.log(`failed; ${retries} retries left.`)),
|
TE.fromIO(
|
||||||
|
ConsoleLogger.log(`failed to find email; ${retries} retries left.`),
|
||||||
|
),
|
||||||
TE.chain(() =>
|
TE.chain(() =>
|
||||||
retries === 0
|
retries === 0
|
||||||
? TE.left(e)
|
? TE.left(e)
|
||||||
|
@ -14,6 +14,7 @@ export interface EmailToInstruction extends EmailInstruction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface EmailJob {
|
export interface EmailJob {
|
||||||
|
requestId: string;
|
||||||
from: EmailFromInstruction;
|
from: EmailFromInstruction;
|
||||||
to: EmailToInstruction;
|
to: EmailToInstruction;
|
||||||
readRetry: Retry;
|
readRetry: Retry;
|
||||||
|
Loading…
Reference in New Issue
Block a user