Skip to content

Commit 492a681

Browse files
committed
chore: mentions webhook api
Signed-off-by: Joana Maia <[email protected]>
1 parent d03e4c8 commit 492a681

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) 2025 The Linux Foundation and each contributor.
2+
// SPDX-License-Identifier: MIT
3+
4+
export default defineEventHandler(async (event) => {
5+
try {
6+
const body = await readBody(event);
7+
const headers = getHeaders(event); // returns an object with all headers
8+
9+
// eslint-disable-next-line no-console
10+
console.log('🔍 Incoming webhook headers:', headers);
11+
// Forward to Tinybird ingestion endpoint
12+
const tinybirdUrl = `${process.env.NUXT_TINYBIRD_EVENTS_API}?name=octolens_projects_mentions&token=${process.env.NUXT_OCTOLENS_TINYBIRD_TOKEN}`;
13+
14+
const res = await fetch(tinybirdUrl, {
15+
method: 'POST',
16+
headers: {
17+
'Content-Type': 'application/json',
18+
},
19+
body: JSON.stringify(body),
20+
});
21+
22+
const response = await res.json();
23+
return response;
24+
} catch (err) {
25+
console.error('Proxy error:', err);
26+
return sendError(
27+
event,
28+
createError({ statusCode: 500, statusMessage: 'Failed to send message to Tinybird' }),
29+
);
30+
}
31+
});

0 commit comments

Comments
 (0)