Skip to content

Commit

Permalink
fix(minor): api and crypto related bugs (#676)
Browse files Browse the repository at this point in the history
* fix: using uncrypto

* feat: changeset
  • Loading branch information
q1zhen authored Jan 6, 2025
1 parent 5343930 commit f4492f4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/violet-cycles-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"enspire": patch
---

bugfixes
4 changes: 3 additions & 1 deletion app/components/custom/club-file-upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ async function download() {
// window.open(data)
downloadLink.value = data.url
downloadFilename.value = data.name
dlink.value.click()
nextTick(() => {
dlink.value.click()
})
downloading.value = false
}
}
Expand Down
7 changes: 7 additions & 0 deletions plugins/crypto.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// TODO: this is a temporary solution to the error
// of occurrence of 'crypto not defined' in prod

export default defineNuxtPlugin(() => {
const crypto = require('uncrypto')
global.crypto = crypto
})
4 changes: 2 additions & 2 deletions server/api/files/newRecord.post.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PrismaClient } from '@prisma/client'
import { v4 as uuidv4 } from 'uuid'
import { randomUUID } from 'uncrypto'

const prisma = new PrismaClient()

Expand Down Expand Up @@ -75,7 +75,7 @@ export default eventHandler(async (event) => {
}
}
catch (error) {
const fileUUID = uuidv4()
const fileUUID = randomUUID()
try {
await prisma.fileUploadRecord.create({
data: {
Expand Down

0 comments on commit f4492f4

Please sign in to comment.