Skip to content

Commit

Permalink
ZK-72: Use nanoid instead of crypto.randomUUID
Browse files Browse the repository at this point in the history
  • Loading branch information
curtisupshall committed Dec 23, 2024
1 parent 47e41b5 commit 6929c5b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
30 changes: 25 additions & 5 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"install": "^0.13.0",
"jsonwebtoken": "^9.0.2",
"lucia": "^3.2.0",
"nanoid": "^5.0.9",
"next": "^15.0.3",
"next-auth": "^4.24.10",
"node-vibrant": "^3.2.1-alpha.1",
Expand Down
3 changes: 2 additions & 1 deletion web/src/pages/migrate/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getDatabaseClient } from '@/database/client'
import { generateGenericUniqueId } from '@/utils/id'
import { Button, Stack, TextField } from '@mui/material'
import { useState } from 'react'

Expand All @@ -12,7 +13,7 @@ export default function MigratePage() {
const records = jsonData.map((record: any) => {
return {
...record,
_id: crypto.randomUUID(),
_id: generateGenericUniqueId(),
}
})
db.bulkDocs(records)
Expand Down
6 changes: 4 additions & 2 deletions web/src/utils/id.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const generateGenericUniqueId = () => {
return crypto.randomUUID()
import { nanoid } from 'nanoid'

export const generateGenericUniqueId = () => {
return nanoid()
}

export const generateJournalEntryId = generateGenericUniqueId
Expand Down

0 comments on commit 6929c5b

Please sign in to comment.