nrx.sh/cli/cli.ts
2025-04-02 00:17:25 +02:00

27 lines
618 B
TypeScript

import { PrismaClient } from "@prisma/client";
import argon2 from "argon2";
async function main() {
const args = process.argv.slice(2);
const username = args[0];
const password = args[1];
if (!username || !password) {
console.error("Usage: node cli.js <username>");
process.exit(1);
}
const hash = await argon2.hash(password, {
type: argon2.argon2id,
memoryCost: 19456,
timeCost: 2,
parallelism: 1,
});
const prisma = new PrismaClient();
await prisma.user.deleteMany({ where: { username } });
await prisma.user.create({ data: { username, password: hash } });
}
main();