-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Expand file tree
/
Copy pathqr.ts
More file actions
66 lines (65 loc) · 1.94 KB
/
Copy pathqr.ts
File metadata and controls
66 lines (65 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { DEFAULT_FGCOLOR, DEFAULT_MARGIN, QR_LEVELS } from "@/lib/qr/constants";
import * as z from "zod/v4";
import { booleanQuerySchema } from "./misc";
import { parseUrlSchema } from "./utils";
export const getQRCodeQuerySchema = z.object({
url: parseUrlSchema.describe("The URL to generate a QR code for."),
logo: z
.string()
.optional()
.describe(
"The logo to include in the QR code. Can only be used with a paid plan on Dub.",
),
size: z.coerce
.number()
.optional()
.default(600)
.describe(
"The size of the QR code in pixels. Defaults to `600` if not provided.",
),
level: z
.enum(QR_LEVELS)
.optional()
.default("L")
.describe(
"The level of error correction to use for the QR code. Defaults to `L` if not provided.",
),
fgColor: z
.string()
.optional()
.default(DEFAULT_FGCOLOR)
.describe(
"The foreground color of the QR code in hex format. Defaults to `#000000` if not provided.",
),
bgColor: z
.string()
.optional()
.describe(
"The background color of the QR code in hex format. Defaults to `#ffffff` for `png`. When omitted for `svg`, the background is transparent.",
),
hideLogo: booleanQuerySchema
.optional()
.default(false)
.describe(
"Whether to hide the logo in the QR code. Can only be used with a paid plan on Dub.",
),
margin: z.coerce
.number()
.optional()
.default(DEFAULT_MARGIN)
.describe(
`The size of the margin around the QR code. Defaults to ${DEFAULT_MARGIN} if not provided.`,
),
includeMargin: booleanQuerySchema
.optional()
.default(true)
.describe(
"DEPRECATED: Margin is included by default. Use the `margin` prop to customize the margin size.",
)
.meta({ deprecated: true }),
format: z
.enum(["png", "svg"])
.optional()
.default("png")
.describe("The format of the QR code. Defaults to `png` if not provided."),
});