fix: Seeding

This commit is contained in:
Andras Bacsai 2022-07-06 11:49:07 +02:00
parent 87ba4560ad
commit 928d53e532

View File

@ -23,7 +23,8 @@ async function main() {
await prisma.setting.create({
data: {
isRegistrationEnabled: true,
isTraefikUsed: true,
proxyPassword: encrypt(generatePassword()),
proxyUser: cuid()
}
});
} else {
@ -73,3 +74,15 @@ main()
.finally(async () => {
await prisma.$disconnect();
});
const encrypt = (text) => {
if (text) {
const iv = crypto.randomBytes(16);
const cipher = crypto.createCipheriv(algorithm, process.env['COOLIFY_SECRET_KEY'], iv);
const encrypted = Buffer.concat([cipher.update(text), cipher.final()]);
return JSON.stringify({
iv: iv.toString('hex'),
content: encrypted.toString('hex')
});
}
};