We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 94f588c commit f12fcc5Copy full SHA for f12fcc5
src/app/api/-/destination/route.ts
@@ -0,0 +1,23 @@
1
+import { NextRequest, NextResponse } from "next/server";
2
+import destination from "^/lib/destination";
3
+
4
+function assureArrayLength(specs: string[]) {
5
+ if (specs.length < 3) {
6
+ return specs as [string] | [string, string];
7
+ }
8
+ throw new Error("Too many specs");
9
+}
10
11
+export async function GET(req: NextRequest, { params }: { params: {} }) {
12
+ const { searchParams } = new URL(req.url);
13
14
+ const specsOrVersions = assureArrayLength(
15
+ searchParams.getAll("specs") ?? "",
16
+ );
17
18
+ console.log("[api/-/destination] running", specsOrVersions);
19
20
+ const result = await destination(specsOrVersions);
21
22
+ return NextResponse.json(result);
23
0 commit comments