3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 04:25:01 +00:00

Consolidate .env files. More work on dev containers.

This commit is contained in:
Dragory 2022-06-26 14:34:54 +03:00
parent 2a959f354c
commit 3773d659cc
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
17 changed files with 137 additions and 106 deletions

View file

@ -1,21 +1,14 @@
import { spawn, Worker, Pool } from "threads";
import "../loadEnv";
import type { CryptFns } from "./cryptWorker";
import { MINUTES } from "../utils";
import { env } from "../env";
if (!process.env.KEY) {
// tslint:disable-next-line:no-console
console.error("Environment value KEY required for encryption");
process.exit(1);
}
const KEY = process.env.KEY;
const pool = Pool(() => spawn(new Worker("./cryptWorker"), { timeout: 10 * MINUTES }), 8);
export async function encrypt(data: string) {
return pool.queue((w) => w.encrypt(data, KEY));
return pool.queue((w) => w.encrypt(data, env.KEY));
}
export async function decrypt(data: string) {
return pool.queue((w) => w.decrypt(data, KEY));
return pool.queue((w) => w.decrypt(data, env.KEY));
}