mirror of
https://github.com/zkldi/Tachi.git
synced 2026-09-26 17:07:58 +03:00
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.
39 lines
860 B
TypeScript
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();
|