A clean and minimal youtube frontend, without all the ads and whistles
JavaScript
refactor: lib and server folder
Christian Fei5aec21bef485
diff --git a/index.js b/index.jsindex b5ebeba..971f248 100644--- a/index.js+++ b/index.js@@ -1,5 +1,5 @@import os from 'os'-import Repository from './server/repository.js'+import Repository from './lib/repository.js'import { createServer } from './server/http.js'async function main ({ port = 3000 } = {}) {diff --git a/server/ffmpeg.js b/lib/ffmpeg.jssimilarity index 100%rename from server/ffmpeg.jsrename to lib/ffmpeg.jsdiff --git a/server/llm/index.js b/lib/llm/index.jssimilarity index 100%rename from server/llm/index.jsrename to lib/llm/index.jsdiff --git a/server/llm/providers/anthropic.js b/lib/llm/providers/anthropic.jssimilarity index 100%rename from server/llm/providers/anthropic.jsrename to lib/llm/providers/anthropic.jsdiff --git a/server/llm/providers/generic.js b/lib/llm/providers/generic.jssimilarity index 100%rename from server/llm/providers/generic.jsrename to lib/llm/providers/generic.jsdiff --git a/server/repository.js b/lib/repository.jssimilarity index 100%rename from server/repository.jsrename to lib/repository.jsdiff --git a/server/subtitles-summary.js b/lib/subtitles-summary.jssimilarity index 94%rename from server/subtitles-summary.jsrename to lib/subtitles-summary.jsindex 140097b..1e7d612 100644--- a/server/subtitles-summary.js+++ b/lib/subtitles-summary.js@@ -1,7 +1,7 @@/* eslint-disable no-async-promise-executor */import fs from 'fs'-import { getVideoSubtitles } from './youtube.js'-import * as llm from './llm/index.js'+import { getVideoSubtitles } from '../lib/youtube.js'+import * as llm from '../lib/llm/index.js'export async function summarizeVideo (id, repo, llmSettings = {}, callback = () => {}) {return new Promise(async (resolve, reject) => {diff --git a/server/update-videos.js b/lib/update-videos.jssimilarity index 100%rename from server/update-videos.jsrename to lib/update-videos.jsdiff --git a/server/youtube.js b/lib/youtube.jssimilarity index 100%rename from server/youtube.jsrename to lib/youtube.jsdiff --git a/server/yt-dlp.js b/lib/yt-dlp.jssimilarity index 100%rename from server/yt-dlp.jsrename to lib/yt-dlp.jsdiff --git a/server/http.js b/server/http.jsindex d7d0274..d960989 100644--- a/server/http.js+++ b/server/http.js@@ -1,10 +1,10 @@import http from 'http'import { URL } from 'url'import { handleSSE, broadcastSSE } from './sse.js'-import { updateAndPersistVideos } from './update-videos.js'+import { updateAndPersistVideos } from '../lib/update-videos.js'import apiHandler from './router/api.js'import appHandler from './router/app.js'-import Repository from './repository.js'+import Repository from '../lib/repository.js'export function createServer (repo = new Repository()) {const stateChangeHandler = {diff --git a/server/router/api.js b/server/router/api.jsindex 558c5ac..92b86e4 100644--- a/server/router/api.js+++ b/server/router/api.js@@ -1,10 +1,10 @@import fs from 'fs'import { URL } from 'url'import querystring from 'querystring'-import { summarizeVideo } from '../subtitles-summary.js'+import { summarizeVideo } from '../../lib/subtitles-summary.js'import { broadcastSSE } from '../sse.js'-import { downloadVideo, extractIdFromUrl, isUnsupportedUrl, isYouTubeUrl } from '../youtube.js'-import { updateAndPersistVideosForChannel } from '../update-videos.js'+import { downloadVideo, extractIdFromUrl, isUnsupportedUrl, isYouTubeUrl } from '../../lib/youtube.js'+import { updateAndPersistVideosForChannel } from '../../lib/update-videos.js'const llmDefaults = {model: 'meta-llama-3.1-8b-instruct',diff --git a/test/llm/index.test.js b/test/llm/index.test.jsindex 26fcdc1..50d9a2d 100644--- a/test/llm/index.test.js+++ b/test/llm/index.test.js@@ -2,7 +2,7 @@ import { test, beforeEach } from 'node:test'import assert from 'node:assert'import { MockAgent, setGlobalDispatcher } from 'undici'-import { summarize } from '../../server/llm/index.js'+import { summarize } from '../../lib/llm/index.js'const system = 'You are a helpful assistant.'const prompt = 'Just tell me something'diff --git a/test/repository.search.test.js b/test/repository.search.test.jsindex a6c0d16..2711993 100644--- a/test/repository.search.test.js+++ b/test/repository.search.test.js@@ -1,7 +1,7 @@import { test, describe } from 'node:test'import fs from 'fs'import assert from 'assert'-import Repository from '../server/repository.js'+import Repository from '../lib/repository.js'let repotest.beforeEach(() => {diff --git a/test/repository.test.js b/test/repository.test.jsindex f473f8d..fffae9f 100644--- a/test/repository.test.js+++ b/test/repository.test.js@@ -1,7 +1,7 @@import { test, describe } from 'node:test'import fs from 'fs'import assert from 'assert'-import Repository from '../server/repository.js'+import Repository from '../lib/repository.js'let repotest.beforeEach(() => {diff --git a/test/search.test.js b/test/search.test.jsindex 6317f2d..d05346f 100644--- a/test/search.test.js+++ b/test/search.test.js@@ -2,7 +2,7 @@ import { test } from 'node:test'import fs from 'fs'import assert from 'assert'import { searchVideosHandler } from '../server/router/api.js'-import Repository from '../server/repository.js'+import Repository from '../lib/repository.js'const req = {}const assertRes = (assertionCb) => ({diff --git a/test/server.test.js b/test/server.test.jsindex a05160e..99144b1 100644--- a/test/server.test.js+++ b/test/server.test.js@@ -2,7 +2,7 @@ import { test, describe, mock } from 'node:test'import fs from 'fs'import assert from 'assert'import { createServer } from '../server/http.js'-import Repository from '../server/repository.js'+import Repository from '../lib/repository.js'mock.timers.enable({ apis: ['setInterval'] })let repodiff --git a/test/subtitles.summary.test.js b/test/subtitles.summary.test.jsindex d09d123..d010912 100644--- a/test/subtitles.summary.test.js+++ b/test/subtitles.summary.test.js@@ -1,6 +1,6 @@import { test } from 'node:test'import assert from 'assert'-import { cleanTranscript } from '../server/subtitles-summary.js'+import { cleanTranscript } from '../lib/subtitles-summary.js'test('cleans transcript', () => {const transcript = `diff --git a/test/youtube.test.js b/test/youtube.test.jsindex 8f39e03..faf99b9 100644--- a/test/youtube.test.js+++ b/test/youtube.test.js@@ -1,6 +1,6 @@import { test } from 'node:test'import assert from 'assert'-import { getVideosFor, getVideo, extractIdFromUrl, isYouTubeUrl, isUnsupportedUrl, isVideoId } from '../server/youtube.js'+import { getVideosFor, getVideo, extractIdFromUrl, isYouTubeUrl, isUnsupportedUrl, isVideoId } from '../lib/youtube.js'if (!process.env.CI) {test('gets videos for channel', async () => {