generated from jellydn/hono-minimal-deno-app
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
env.ts
25 lines (23 loc) · 631 Bytes
/
env.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import "dotenv/load.ts";
import { cleanEnv, str } from "envalid";
import { logger } from "./logger.ts";
const report = (error: string) => {
logger.error(error);
};
export const env = cleanEnv(
Deno.env.toObject(),
{
JWT_TOKEN: str({
desc: "your twitter token",
docs: "https://developer.twitter.com/en/docs/tutorials/step-by-step-guide-to-making-your-first-request-to-the-twitter-api-v2",
}),
},
{
reporter: ({ errors, env }) => {
if (Object.keys(errors).length > 0) {
report(`Invalid environment variables: ${Object.keys(errors)}`);
logger.info(env);
}
},
}
);