Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
♻️ Remove legacy poll routes (#2173)
Luke Vellaed2950cc6684
diff --git a/apps/web/next.config.ts b/apps/web/next.config.tsindex 141f95711..be46bd312 100644--- a/apps/web/next.config.ts+++ b/apps/web/next.config.ts@@ -76,6 +76,18 @@ const nextConfig: NextConfig = {},];},+ async rewrites() {+ return [+ {+ source: "/p/:participantUrlId",+ destination: "/api/legacy/p/:participantUrlId",+ },+ {+ source: "/admin/:adminUrlId",+ destination: "/api/legacy/admin/:adminUrlId",+ },+ ];+ },devIndicators: {position: "bottom-right",},diff --git a/apps/web/src/app/[locale]/admin/[adminUrlId]/page.tsx b/apps/web/src/app/[locale]/admin/[adminUrlId]/page.tsxdeleted file mode 100644index 1d8d7061d..000000000--- a/apps/web/src/app/[locale]/admin/[adminUrlId]/page.tsx+++ /dev/null@@ -1,28 +0,0 @@-import { prisma } from "@rallly/database";-import { absoluteUrl } from "@rallly/utils/absolute-url";-import { notFound } from "next/navigation";--import { Redirect } from "@/app/components/redirect";--import type { PParams } from "./types";--export default async function Page(props: { params: Promise<PParams> }) {- const params = await props.params;- const { adminUrlId } = params;-- const poll = await prisma.poll.findUnique({- where: { adminUrlId },- select: { id: true },- });-- if (!poll) {- notFound();- }-- return (- <Redirect- from={absoluteUrl(`/admin/${params.adminUrlId}`)}- href={absoluteUrl(`/poll/${poll.id}`)}- />- );-}diff --git a/apps/web/src/app/[locale]/admin/[adminUrlId]/types.ts b/apps/web/src/app/[locale]/admin/[adminUrlId]/types.tsdeleted file mode 100644index ab9aefb9b..000000000--- a/apps/web/src/app/[locale]/admin/[adminUrlId]/types.ts+++ /dev/null@@ -1,5 +0,0 @@-import type { Params } from "@/app/[locale]/types";--export interface PParams extends Params {- adminUrlId: string;-}diff --git a/apps/web/src/app/[locale]/p/[participantUrlId]/page.tsx b/apps/web/src/app/[locale]/p/[participantUrlId]/page.tsxdeleted file mode 100644index c7cb3df0a..000000000--- a/apps/web/src/app/[locale]/p/[participantUrlId]/page.tsx+++ /dev/null@@ -1,28 +0,0 @@-import { prisma } from "@rallly/database";-import { absoluteUrl } from "@rallly/utils/absolute-url";-import { notFound } from "next/navigation";--import { Redirect } from "@/app/components/redirect";--import type { PParams } from "./types";--export default async function Page(props: { params: Promise<PParams> }) {- const params = await props.params;- const { participantUrlId } = params;-- const poll = await prisma.poll.findUnique({- where: { participantUrlId },- select: { id: true },- });-- if (!poll) {- notFound();- }-- return (- <Redirect- from={absoluteUrl(`/p/${params.participantUrlId}`)}- href={absoluteUrl(`/invite/${poll.id}`)}- />- );-}diff --git a/apps/web/src/app/[locale]/p/[participantUrlId]/types.ts b/apps/web/src/app/[locale]/p/[participantUrlId]/types.tsdeleted file mode 100644index 25635176c..000000000--- a/apps/web/src/app/[locale]/p/[participantUrlId]/types.ts+++ /dev/null@@ -1,5 +0,0 @@-import type { Params } from "@/app/[locale]/types";--export interface PParams extends Params {- participantUrlId: string;-}diff --git a/apps/web/src/app/api/legacy/[...route]/route.ts b/apps/web/src/app/api/legacy/[...route]/route.tsnew file mode 100644index 000000000..73a0111fe--- /dev/null+++ b/apps/web/src/app/api/legacy/[...route]/route.ts@@ -0,0 +1,35 @@+import { prisma } from "@rallly/database";+import { Hono } from "hono";+import { handle } from "hono/vercel";++const app = new Hono().basePath("/api/legacy");++app.get("/p/:participantUrlId", async (c) => {+ const poll = await prisma.poll.findUnique({+ where: { participantUrlId: c.req.param("participantUrlId") },+ select: { id: true },+ });++ if (!poll) {+ return c.notFound();+ }++ c.header("Cache-Control", "public, max-age=31536000, immutable");+ return c.redirect(`/invite/${poll.id}`, 301);+});++app.get("/admin/:adminUrlId", async (c) => {+ const poll = await prisma.poll.findUnique({+ where: { adminUrlId: c.req.param("adminUrlId") },+ select: { id: true },+ });++ if (!poll) {+ return c.notFound();+ }++ c.header("Cache-Control", "public, max-age=31536000, immutable");+ return c.redirect(`/poll/${poll.id}`, 301);+});++export const GET = handle(app);