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:
33
lib/passwords.ts
Normal file
33
lib/passwords.ts
Normal 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)
|
||||
})
|
||||
Reference in New Issue
Block a user