Files
zkldi_Tachi/github-bot/src/config.ts
T
zkldi 5dff2ee805 fix: change prudence's default export to named
this was causing issues with vite and is potentially a bug in prudence
or in vite. it's very hard to tell and i've already spent
3 hours trying to fix this, so here.
2022-12-23 09:04:25 +00:00

39 lines
860 B
TypeScript

import { config } from "dotenv";
import { p } from "prudence";
// init dotenv
config();
function ParseEnvVars() {
const err = p(
process.env,
{
APP_ID: "string",
WEBHOOK_SECRET: "string",
BASE64_PRIVATE_KEY: "string",
PORT: (self) =>
p.isPositiveInteger(Number(self)) === true ||
"Should be a string representing a whole integer port.",
CLIENT_SECRET: "string",
CLIENT_ID: "string",
},
{},
{ allowExcessKeys: true }
);
if (err) {
throw new Error(`${err.keychain}: ${err.message}`);
}
return {
appId: process.env.APP_ID!,
webhookSecret: process.env.WEBHOOK_SECRET!,
port: process.env.PORT!,
privateKey: Buffer.from(process.env.BASE64_PRIVATE_KEY!, "base64").toString("utf-8"),
clientID: process.env.CLIENT_ID!,
clientSecret: process.env.CLIENT_SECRET!,
};
}
export const ProcessEnv = ParseEnvVars();