39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
|
// Follow this setup guide to integrate the Deno language server with your editor:
|
||
|
// https://deno.land/manual/getting_started/setup_your_environment
|
||
|
// This enables autocomplete, go to definition, etc.
|
||
|
|
||
|
import { serve } from "https://deno.land/std@0.177.0/http/server.ts";
|
||
|
import { Redis } from "https://deno.land/x/upstash_redis@v1.19.3/mod.ts";
|
||
|
|
||
|
serve(async (req) => {
|
||
|
console.log('hello we are executing');
|
||
|
|
||
|
const redis = new Redis({
|
||
|
url: Deno.env.get("UPSTASH_REDIS_REST_URL")!,
|
||
|
token: Deno.env.get("UPSTASH_REDIS_REST_TOKEN")!,
|
||
|
});
|
||
|
|
||
|
console.log('attempting to get text');
|
||
|
|
||
|
const text = await req.text();
|
||
|
console.log(text);
|
||
|
redis.set('hello_from_supabase', text);
|
||
|
console.log('set in redis');
|
||
|
|
||
|
return new Response(JSON.stringify({ "status": "success" }), {
|
||
|
headers: { "Content-Type": "application/json" },
|
||
|
});
|
||
|
});
|
||
|
|
||
|
/* To invoke locally:
|
||
|
|
||
|
1. Run `supabase start` (see: https://supabase.com/docs/reference/cli/supabase-start)
|
||
|
2. Make an HTTP request:
|
||
|
|
||
|
curl -i --location --request POST 'http://127.0.0.1:54321/functions/v1/test' \
|
||
|
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0' \
|
||
|
--header 'Content-Type: application/json' \
|
||
|
--data '{"name":"Functions"}'
|
||
|
|
||
|
*/
|