blob: 26e11580507e120e4dd31d6128c07d6d10ca661e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
|
import { Either, type IEither } from "@emprespresso/pengueno";
export const getRequiredEnv = (name: string): IEither<Error, string> =>
Either
.fromFailable<Error, string | undefined>(() => Deno.env.get(name)) // could throw when no permission.
.flatMap((v) =>
(v &&
Either.right(v)) ||
Either.left(
new Error(`environment variable "${name}" is required D:`),
)
);
|