version con express js que no funciona

This commit is contained in:
2026-02-25 12:17:59 -06:00
parent dcaeeb72dd
commit 8aeb1d0a64
10 changed files with 4445 additions and 3 deletions
+1 -1
View File
@@ -1 +1 @@
v2.185.0
v2.187.0
+1 -1
View File
@@ -1 +1 @@
buckets-objects-grants-postgres
fix-optimized-search-function
+1 -1
View File
@@ -1 +1 @@
v1.33.0
v1.37.7
+11
View File
@@ -48,3 +48,14 @@ entrypoint = "./functions/generate-subject-suggestions/index.ts"
# Specifies static files to be bundled with the function. Supports glob patterns.
# For example, if you want to serve static HTML pages in your function:
# static_files = [ "./functions/generate-subject-suggestions/*.html" ]
[functions.openai-webhook-responses]
enabled = true
verify_jwt = true
import_map = "./functions/openai-webhook-responses/deno.json"
# Uncomment to specify a custom file path to the entrypoint.
# Supported file extensions are: .ts, .js, .mjs, .jsx, .tsx
entrypoint = "./functions/openai-webhook-responses/index.ts"
# Specifies static files to be bundled with the function. Supports glob patterns.
# For example, if you want to serve static HTML pages in your function:
# static_files = [ "./functions/openai-webhook-responses/*.html" ]
+2481
View File
File diff suppressed because one or more lines are too long
@@ -0,0 +1,3 @@
# Configuration for private npm package dependencies
# For more information on using private registries with Edge Functions, see:
# https://supabase.com/docs/guides/functions/import-maps#importing-from-private-registries
@@ -0,0 +1,7 @@
{
"imports": {
"@supabase/functions-js/edge-runtime.d.ts": "jsr:@supabase/functions-js@^2/edge-runtime.d.ts",
"express": "npm:express@5.2.1",
"openai": "npm:openai@6.16.0"
}
}
@@ -0,0 +1,48 @@
// 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.
// Setup type definitions for built-in Supabase Runtime APIs
import "@supabase/functions-js/edge-runtime.d.ts";
import express from "express";
import OpenAI from "openai";
const app = express();
const client = new OpenAI({
webhookSecret: Deno.env.get("OPENAI_WEBHOOK_SECRET"),
});
app.use(express.text({ type: "application/json" }));
app.post("/webhook", async (req: express.Request, res: express.Response) => {
try {
const event = await client.webhooks.unwrap(req.body, req.headers);
if (event.type === "response.completed") {
const response_id = event.data.id;
const response = await client.responses.retrieve(response_id);
const output_text = response.output
.filter((item) => item.type === "message")
.flatMap((item) => item.content)
.filter((contentItem) => contentItem.type === "output_text")
.map((contentItem) => contentItem.text)
.join("");
console.log("Response output:", output_text);
}
res.status(200).send();
} catch (error) {
if (error instanceof OpenAI.InvalidWebhookSignatureError) {
console.error("Invalid signature", error);
res.status(400).send("Invalid signature");
} else {
throw error;
}
}
});
Deno.serve(async (req) => {
console.log("Inicio de openai-webhook-responses");
return await app.handle(req);
});
+1888
View File
File diff suppressed because it is too large Load Diff