Skip to content

Commit

Permalink
connect stream endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
juandjara committed Nov 20, 2023
1 parent 5496499 commit 8ce5995
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/routes/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from 'axios'
import { Request, Response } from 'express'
import getAudioStreamDetails from '../lib/getAudioStreamDetails'

export async function stream(req: Request, res: Response) {
export default async function stream(req: Request, res: Response) {
const id = req.params.ytid
const streamDef = await getAudioStreamDetails(id, 'audio/webm')
const response = await axios.get(streamDef.url, { responseType: 'stream' })
Expand Down
4 changes: 3 additions & 1 deletion api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import pkg from '../package.json' assert { type: 'json' }
import cors from 'cors'
// @ts-ignore
import sendSeekable from 'send-seekable'
import { stream } from './routes/stream'
import stream from './routes/stream'
import download from './routes/download'
import autocomplete from './routes/autocomplete'
import search from './routes/search'
import stoppable from 'stoppable'

const app = express()
Expand All @@ -27,6 +28,7 @@ app.get('/api', (_, res) => {
app.get('/api/stream/:ytid', stream)
app.get('/api/dl/:ytid', download)
app.get('/api/autocomplete', autocomplete)
app.get('/api/search', search)

const PORT = Number(process.env.PORT || 3000)

Expand Down

0 comments on commit 8ce5995

Please sign in to comment.