Skip to content

Commit

Permalink
Adds revalidate API route
Browse files Browse the repository at this point in the history
  • Loading branch information
borisghidaglia committed Oct 14, 2024
1 parent 5c6808b commit fbc6c2c
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 79 deletions.
16 changes: 16 additions & 0 deletions app/revalidate/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { revalidateTag } from "next/cache";

export async function POST(request: Request) {
const apiKey = request.headers.get("api-key");
if (apiKey === null || apiKey !== process.env.REVALIDATE_API_KEY!)
return new Response("Denied");

const tags = (await request.json()).tags as string[] | undefined;
if (tags === undefined) return new Response("No tags provided");

for (const tag of tags) {
revalidateTag(tag);
}

return new Response("Done");
}
162 changes: 90 additions & 72 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions scripts/checkAddressType.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// @ts-nocheck

import { writeFileSync } from "fs";
// import { getAllCities } from "./common";
import { getAllCities } from "./common";

import cities from "./cities.json";

async function main() {
Expand Down Expand Up @@ -27,7 +30,7 @@ async function main() {
writeFileSync("./scripts/notCities.json", JSON.stringify(notCities));
}

main();
// main();

const wait = (duration: number) =>
new Promise((resolve) => setTimeout(resolve, duration));
Loading

0 comments on commit fbc6c2c

Please sign in to comment.