Skip to content

Commit 2c6bf23

Browse files
committed
chore: cleanup
1 parent 2ccab2a commit 2c6bf23

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

lib/server.js

+21-19
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,27 @@ export function createServer ({repo, connections = []}) {
160160
res.end('Download started')
161161
}
162162

163+
164+
async function ignoreVideoHandler(req, res, repo, connections = []) {
165+
const body = await getBody(req)
166+
let { id } = JSON.parse(body)
167+
res.writeHead(200, { 'Content-Type': 'application/json' })
168+
return res.end(JSON.stringify(repo.toggleIgnoreVideo(id)))
169+
}
170+
171+
async function deleteVideoHandler(req, res, repo, connections = []) {
172+
const body = await getBody(req)
173+
let { id } = JSON.parse(body)
174+
try {
175+
repo.deleteVideo(id)
176+
res.writeHead(200)
177+
res.end()
178+
} catch (err) {
179+
res.writeHead(500)
180+
res.end()
181+
}
182+
}
183+
163184
function watchVideoHandler(req, res) {
164185
const videoPath = './data' + req.url + '.mp4'
165186
if (!fs.existsSync(videoPath)) {
@@ -281,23 +302,4 @@ export function createServer ({repo, connections = []}) {
281302
}
282303
}
283304

284-
async function ignoreVideoHandler(req, res, repo, connections = []) {
285-
const body = await getBody(req)
286-
let { id } = JSON.parse(body)
287-
res.writeHead(200, { 'Content-Type': 'application/json' })
288-
return res.end(JSON.stringify(repo.toggleIgnoreVideo(id)))
289-
}
290-
291-
async function deleteVideoHandler(req, res, repo, connections = []) {
292-
const body = await getBody(req)
293-
let { id } = JSON.parse(body)
294-
try {
295-
repo.deleteVideo(id)
296-
res.writeHead(200)
297-
res.end()
298-
} catch (err) {
299-
res.writeHead(500)
300-
res.end()
301-
}
302-
}
303305
}

0 commit comments

Comments
 (0)