From 7e40aa188979311e706154dfcf52e47975f99cde Mon Sep 17 00:00:00 2001 From: Elad Rosenheim Date: Tue, 23 Apr 2024 17:55:24 +0300 Subject: Revalidation & Blobs pages, tweaks (#8) * added blobs.astro page * updated blobs * updated index.astro and npm dependencies * updated api blobs * Revalidation example WIP * Revalidation by tag example * Update revalidation.astro * Image CDN fixes * Text fixes * updated colors (#9) * updated colors * updated README.md * updated Layout.astro bg color * updated template colors * Inline Inter font * Inline noise.png * Remove remaining "Astro.js" --------- Co-authored-by: TomasBankauskas --- src/pages/api/blobs.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/pages/api/blobs.ts (limited to 'src/pages/api/blobs.ts') diff --git a/src/pages/api/blobs.ts b/src/pages/api/blobs.ts new file mode 100644 index 0000000..d11aa58 --- /dev/null +++ b/src/pages/api/blobs.ts @@ -0,0 +1,27 @@ +import type { APIRoute } from 'astro'; +import { getStore } from '@netlify/blobs'; + +export const prerender = false; + +export const POST: APIRoute = async ({ request }) => { + const parameters = await request.json(); + const blobStore = getStore('shapes'); + const key = parameters.name; + await blobStore.setJSON(key, parameters); + return new Response( + JSON.stringify({ + message: `Stored shape "${key}"` + }) + ); +}; + +export const GET: APIRoute = async ({ request }) => { + const blobStore = getStore({ name: 'shapes', consistency: 'strong' }); + const data = await blobStore.list(); + const keys = data.blobs.map(({ key }) => key); + return new Response( + JSON.stringify({ + keys + }) + ); +}; -- cgit v1.2.3