Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
svglol committed Apr 27, 2024
1 parent 9775a27 commit 05218c8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@vueuse/nuxt": "10.9.0",
"drizzle-orm": "0.30.9",
"nuxt": "3.11.2",
"qr-image": "3.2.0",
"uuid": "9.0.1",
"zod": "3.23.4"
},
Expand All @@ -34,6 +35,7 @@
"@nuxt/devtools": "1.2.0",
"@nuxt/eslint": "^0.3.10",
"@nuxt/test-utils": "3.12.1",
"@types/qr-image": "3.2.9",
"@types/uuid": "9.0.8",
"@vue/test-utils": "2.4.5",
"drizzle-kit": "0.20.17",
Expand Down
18 changes: 18 additions & 0 deletions pnpm-lock.yaml

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

19 changes: 19 additions & 0 deletions server/api/qrcode.get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { z } from 'zod'

import qr from 'qr-image'

export default eventHandler<{ query: { text: string, size?: string } }>(async (event) => {
const { text, size } = await getValidatedQuery(event, z.object({
text: z.string().min(1),
size: z.number().optional(),
}).parse)

const qr_png = qr.imageSync(text, { size: size || 5 })

const response = new Response(qr_png, {
headers: {
'Content-Type': 'image/png',
},
})
return response
})

0 comments on commit 05218c8

Please sign in to comment.