Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: add app ping url #2380

Merged
merged 2 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/api/src/router/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ export const appRouter = createTRPCRouter({
}),
selectable: protectedProcedure
.input(z.void())
.output(z.array(selectAppSchema.pick({ id: true, name: true, iconUrl: true, href: true, description: true })))
.output(
z.array(
selectAppSchema.pick({ id: true, name: true, iconUrl: true, href: true, pingUrl: true, description: true }),
),
)
.meta({
openapi: {
method: "GET",
Expand All @@ -73,6 +77,7 @@ export const appRouter = createTRPCRouter({
iconUrl: true,
description: true,
href: true,
pingUrl: true,
},
orderBy: asc(apps.name),
});
Expand Down Expand Up @@ -121,6 +126,7 @@ export const appRouter = createTRPCRouter({
description: input.description,
iconUrl: input.iconUrl,
href: input.href,
pingUrl: input.pingUrl === "" ? null : input.pingUrl,
});

return { appId: id };
Expand Down Expand Up @@ -164,6 +170,7 @@ export const appRouter = createTRPCRouter({
description: input.description,
iconUrl: input.iconUrl,
href: input.href,
pingUrl: input.pingUrl === "" ? null : input.pingUrl,
})
.where(eq(apps.id, input.id));
}),
Expand Down
6 changes: 6 additions & 0 deletions packages/api/src/router/test/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ describe("create should create a new app with all arguments", () => {
description: "React components and hooks library",
iconUrl: "https://mantine.dev/favicon.svg",
href: "https://mantine.dev",
pingUrl: "https://mantine.dev/a",
};

// Act
Expand All @@ -170,6 +171,7 @@ describe("create should create a new app with all arguments", () => {
expect(dbApp!.description).toBe(input.description);
expect(dbApp!.iconUrl).toBe(input.iconUrl);
expect(dbApp!.href).toBe(input.href);
expect(dbApp!.pingUrl).toBe(input.pingUrl);
});

test("should create a new app only with required arguments", async () => {
Expand All @@ -185,6 +187,7 @@ describe("create should create a new app with all arguments", () => {
description: null,
iconUrl: "https://mantine.dev/favicon.svg",
href: null,
pingUrl: "",
};

// Act
Expand All @@ -197,6 +200,7 @@ describe("create should create a new app with all arguments", () => {
expect(dbApp!.description).toBe(input.description);
expect(dbApp!.iconUrl).toBe(input.iconUrl);
expect(dbApp!.href).toBe(input.href);
expect(dbApp!.pingUrl).toBe(null);
});
});

Expand Down Expand Up @@ -225,6 +229,7 @@ describe("update should update an app", () => {
description: "React components and hooks library",
iconUrl: "https://mantine.dev/favicon.svg2",
href: "https://mantine.dev",
pingUrl: "https://mantine.dev/a",
};

// Act
Expand Down Expand Up @@ -257,6 +262,7 @@ describe("update should update an app", () => {
iconUrl: "https://mantine.dev/favicon.svg",
description: null,
href: null,
pingUrl: "",
});

// Assert
Expand Down
1 change: 1 addition & 0 deletions packages/db/migrations/mysql/0028_add_app_ping_url.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `app` ADD `ping_url` text;
Loading