File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
frontend/server/api/octolens Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments