Consolidate .env files. More work on dev containers.
This commit is contained in:
parent
2a959f354c
commit
3773d659cc
17 changed files with 137 additions and 106 deletions
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue