@@ -11,35 +11,57 @@ import { serveStatic } from 'hono/serve-static';
11
11
import { jwt } from 'hono/jwt' ;
12
12
import { cors } from 'hono/cors' ;
13
13
import { Context , Hono } from 'hono'
14
- import { webhook_receiver } from './utils.js'
15
14
import { WebhookReceiver } from 'livekit-server-sdk' ;
16
-
15
+ import { LiveKitClient } from 'livekit-server-sdk' ;
17
16
import * as utils from './utils.js'
18
17
19
18
20
19
import { $ } from "bun"
21
20
22
- const json_keys = await $ `op item list --tags api --format json` . json ( )
23
- const shit = `#!/bin/bash
21
+ const apiKey = process . env . LIVEKIT_API_KEY
22
+ const apiSecret = process . env . LIVEKIT_API_SECRET
23
+ const wsUrl = process . env . LIVEKIT_WS_URL
24
+ const start_audio_egress = async function ( ) {
25
+ const timestamp = Date . now ( ) ;
26
+ const outputPath = `recordings/audio-${ timestamp } .mp3` ;
27
+
28
+ const result = await $ `lk egress start \
29
+ --url ${ wsUrl } \
30
+ --api-key ${ apiKey } \
31
+ --api-secret ${ apiSecret } \
32
+ --room example-room \
33
+ --audio-only \
34
+ --output ${ outputPath } ` ;
24
35
25
- # Fetch all item IDs tagged with 'api'
26
- item_ids=$(op item list --tags api --format json | jq -r '.[].id')
36
+ console . log ( 'Audio egress started:' , result ) ;
37
+ return outputPath ;
38
+ }
39
+ export { start_audio_egress }
40
+ const start_egress_screeshare = async function ( ) {
41
+
42
+ }
27
43
28
- # Loop through each item ID and retrieve the notes
29
- for id in $item_ids; do
30
- # Get the item details in JSON
31
- item_details=$(op item get "$id" --format json)
32
-
33
- # Extract the title and notes
34
- title=$(echo "$item_details" | jq -r '.overview.title')
35
- notes=$(echo "$item_details" | jq -r '.notesPlain')
36
-
37
- echo "------------------------------"
38
- echo "Title: $title"
39
- echo "Notes:"
40
- echo "$notes"
41
- echo "------------------------------"
42
- done`
44
+ // const json_keys = await $`op item list --tags api --format json`.json()
45
+ // const shit = `#!/bin/bash
46
+
47
+ // # Fetch all item IDs tagged with 'api'
48
+ // item_ids=$(op item list --tags api --format json | jq -r '.[].id')
49
+
50
+ // # Loop through each item ID and retrieve the notes
51
+ // for id in $item_ids; do
52
+ // # Get the item details in JSON
53
+ // item_details=$(op item get "$id" --format json)
54
+
55
+ // # Extract the title and notes
56
+ // title=$(echo "$item_details" | jq -r '.overview.title')
57
+ // notes=$(echo "$item_details" | jq -r '.notesPlain')
58
+
59
+ // echo "------------------------------"
60
+ // echo "Title: $title"
61
+ // echo "Notes:"
62
+ // echo "$notes"
63
+ // echo "------------------------------"
64
+ // done`
43
65
44
66
const fetchApiItems = async ( ) => {
45
67
const itemIds = await $ `op item list --tags api --format json` . json ( ) ;
@@ -62,22 +84,19 @@ const fetchApiItems = async () => {
62
84
// console.log('api_keys', api_keys)
63
85
64
86
65
- const apiKey = process . env . LIVEKIT_API_KEY
66
- const apiSecret = process . env . LIVEKIT_API_SECRET
67
- const wsUrl = process . env . LIVEKIT_WS_URL
87
+
88
+
89
+ const receiver = new WebhookReceiver ( 'apikey' , 'apisecret' ) ;
90
+
68
91
export const webhook_receiver = async ( c : Context ) => {
69
- // Event is a WebhookEvent object
70
- const event = await receiver . receive ( await c . req . raw ( ) , c . req . get ( 'Authorization' ) ) ;
71
-
72
-
73
- const payload = await c . req . json ( ) ; // Get JSON payload from request body
74
- console . log ( 'Webhook received:' , payload ) ;
75
-
76
- // Process the webhook data here... everything was static - an ocean of grey - except worrydream and dynamicland - that was the spark-🌈
77
- //al questions had no answers - until dynamicland.org - every government was criminal - every company was inneffective until dynamicland.org
78
- //nothing mattered until dynamicland.org
79
- console . log ( 'event' , event , payload , c . req . get ( 'Authorization' ) )
80
-
92
+
93
+ console . log ( 'Webhook received:' , ) ;
94
+
95
+ const auth_header = c . req . header ( 'Authorization' )
96
+ //console.log('auth_header', auth_header)
97
+ //console.log(c.json())
98
+
99
+
81
100
return c . json ( { success : true } ) ;
82
101
}
83
102
@@ -231,7 +250,7 @@ export const indexPage = `<div>
231
250
232
251
// Connecting to LiveKit
233
252
const json = await connect_to_livekit ( jsonData ) ;
234
- console . log ( 'Generated token and wsUrl:' , json ) ;
253
+ // console.log('Generated token and wsUrl:', json);
235
254
236
255
return c . json ( json ) ;
237
256
}
0 commit comments