Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Retrieve a QR code

Kiran Kc721fa0cc29f
diff --git a/apps/web/lib/openapi/links/create-bulk-link.ts b/apps/web/lib/openapi/links/create-bulk-link.ts
index 36e2f640ab..b3d2006915 100644
--- a/apps/web/lib/openapi/links/create-bulk-link.ts
+++ b/apps/web/lib/openapi/links/create-bulk-link.ts
@@ -8,7 +8,7 @@ import {
import z from "@/lib/zod";
export const createBulkLink: ZodOpenApiOperationObject = {
- operationId: "createBulkLink",
+ operationId: "bulkCreateLinks",
summary: "Bulk create links",
description: "Bulk create up to 100 links for the authenticated project.",
requestParams: {
diff --git a/apps/web/lib/openapi/links/get-qr.ts b/apps/web/lib/openapi/links/get-qr.ts
new file mode 100644
index 0000000000..0671dae899
--- /dev/null
+++ b/apps/web/lib/openapi/links/get-qr.ts
@@ -0,0 +1,25 @@
+import { ZodOpenApiOperationObject } from "zod-openapi";
+
+import z from "@/lib/zod";
+import { GetQRCodeQuerySchema } from "@/lib/zod/schemas/qr";
+
+export const getQRCode: ZodOpenApiOperationObject = {
+ operationId: "getQRCode",
+ summary: "Retrieve a QR code",
+ description: "Retrieve a QR code for a link.",
+ requestParams: {
+ query: GetQRCodeQuerySchema,
+ },
+ responses: {
+ "200": {
+ description: "The QR code",
+ content: {
+ "image/png": {
+ schema: z.string(),
+ },
+ },
+ },
+ },
+ tags: ["Links"],
+ security: [{ bearerToken: [] }],
+};
diff --git a/apps/web/lib/openapi/links/index.ts b/apps/web/lib/openapi/links/index.ts
index 8514d056b2..911891faef 100644
--- a/apps/web/lib/openapi/links/index.ts
+++ b/apps/web/lib/openapi/links/index.ts
@@ -6,6 +6,7 @@ import { getLinkInfo } from "./get-link-info";
import { deleteLink } from "./delete-link";
import { editLink } from "./edit-link";
import { createBulkLink } from "./create-bulk-link";
+import { getQRCode } from "./get-qr";
export const linksPaths: ZodOpenApiPathsObject = {
"/links": {
@@ -21,5 +22,8 @@ export const linksPaths: ZodOpenApiPathsObject = {
},
"/links/bulk": {
post: createBulkLink,
- }
+ },
+ "/qr": {
+ get: getQRCode,
+ },
};
diff --git a/apps/web/lib/openapi/projects/get-project-info.ts b/apps/web/lib/openapi/projects/get-project-info.ts
index 159f69bc0e..e151540019 100644
--- a/apps/web/lib/openapi/projects/get-project-info.ts
+++ b/apps/web/lib/openapi/projects/get-project-info.ts
@@ -4,7 +4,7 @@ import z from "@/lib/zod";
import { ProjectSchema } from "@/lib/zod/schemas/projects";
export const getProjectInfo: ZodOpenApiOperationObject = {
- operationId: "getProjectInfo",
+ operationId: "getProject",
summary: "Retrieve a project",
description: "Retrieve a project for the authenticated user.",
requestParams: {
diff --git a/apps/web/lib/zod/schemas/qr.ts b/apps/web/lib/zod/schemas/qr.ts
new file mode 100644
index 0000000000..9948281359
--- /dev/null
+++ b/apps/web/lib/zod/schemas/qr.ts
@@ -0,0 +1,47 @@
+import z from "@/lib/zod";
+
+export const GetQRCodeQuerySchema = z.object({
+ url: z
+ .string()
+ .url()
+ .optional()
+ .default("https://dub.co")
+ .describe(
+ "The URL to generate a QR code for. Defaults to `https://dub.co` if not provided.",
+ ),
+ size: z
+ .number()
+ .optional()
+ .default(600)
+ .describe(
+ "The size of the QR code in pixels. Defaults to `600` if not provided.",
+ ),
+ level: z
+ .enum(["L", "M", "Q", "H"])
+ .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("#000000")
+ .describe(
+ "The foreground color of the QR code in hex format. Defaults to `#000000` if not provided.",
+ ),
+ bgColor: z
+ .string()
+ .optional()
+ .default("#ffffff")
+ .describe(
+ "The background color of the QR code in hex format. Defaults to `#ffffff` if not provided.",
+ ),
+ includeMargin: z.coerce
+ .boolean()
+ .optional()
+ .default(false)
+ .describe(
+ "Whether to include a margin around the QR code. Defaults to `false` if not provided.",
+ ),
+});