3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-08 03:27:20 +00:00
zeppelin/backend/src/utils/crypt.ts
Dragory 45e3fe2ef0
chore: esm imports
This will make merging this into 'next' much easier.
2024-08-11 21:58:52 +03:00

14 lines
450 B
TypeScript

import { Pool, spawn, Worker } from "threads";
import { env } from "../env.js";
import "../threadsSignalFix.js";
import { MINUTES } from "../utils.js";
const pool = Pool(() => spawn(new Worker("./cryptWorker"), { timeout: 10 * MINUTES }), 8);
export async function encrypt(data: string) {
return pool.queue((w) => w.encrypt(data, env.KEY));
}
export async function decrypt(data: string) {
return pool.queue((w) => w.decrypt(data, env.KEY));
}