1
0
mirror of https://github.com/Fayorg/calendrier-avant.git synced 2026-05-27 17:18:38 +02:00

fix: moved password generator file to lib

This commit is contained in:
2023-12-04 14:04:10 +01:00
parent dc6a4504c1
commit e2709760cd

33
lib/passwords.ts Normal file
View File

@@ -0,0 +1,33 @@
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
let users = 24
let keys = []
let keyLength = 8
let chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
async function main() {
// ... you will write your Prisma Client queries here
for (let i = 1; i <= users; i++) {
let key = ''
for (let j = 0; j < keyLength; j++) {
key += chars.charAt(Math.floor(Math.random() * chars.length))
}
await prisma.keys.create({
data: {
key: key
}
})
}
}
main()
.then(async () => {
await prisma.$disconnect()
})
.catch(async (e) => {
console.error(e)
await prisma.$disconnect()
process.exit(1)
})