blob: c3ae800c160e66098ec53114582dc55e00539a2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
|
import { Either, type IEither } from "@emprespresso/utils";
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:`),
)
);
|