@@ -38,6 +38,8 @@ export function createServer ({repo, connections = []}) {
38
38
/* api */
39
39
if ( url . pathname === '/api/channels' && req . method === 'POST' )
40
40
return addChannelHandler ( req , res , repo , connections )
41
+ if ( url . pathname === '/api/channels' && req . method === 'GET' )
42
+ return getChannelHandler ( req , res , repo , connections )
41
43
if ( url . pathname === '/api/download-video' && req . method === 'POST' )
42
44
return downloadVideoHandler ( req , res , repo , connections )
43
45
if ( url . pathname === '/api/summarize-video' && req . method === 'POST' )
@@ -132,6 +134,12 @@ export function createServer ({repo, connections = []}) {
132
134
return res . end ( 'Channel not found' )
133
135
}
134
136
137
+ async function getChannelHandler ( req , res , repo , connections = [ ] ) {
138
+ const channels = repo . getChannels ( )
139
+ res . writeHead ( 200 , { 'Content-Type' : 'application/json' } )
140
+ return res . end ( JSON . stringify ( channels ) )
141
+ }
142
+
135
143
async function downloadVideoHandler ( req , res , repo , connections = [ ] ) {
136
144
const body = await getBody ( req )
137
145
let { id, external } = JSON . parse ( body )
0 commit comments