From a93cfd201d2e83540cb0e1082e7a7843760b701e Mon Sep 17 00:00:00 2001 From: "Satsuki Akiba (aider)" Date: Wed, 4 Jun 2025 11:29:18 +0900 Subject: [PATCH] feat: Apply fixes for type errors and unused variables --- frontend/src/App.tsx | 1 - frontend/src/app/page.tsx | 1 - frontend/src/components/EpisodePlayer.tsx | 5 +---- frontend/src/components/FeedList.tsx | 6 +----- scripts/fetch_and_generate.ts | 16 ++++++++++------ server.ts | 19 ++++++++++++------- services/database.ts | 2 +- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 93460ed..2710c9f 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import './app/globals.css'; import RootLayout from './app/layout'; import Home from './app/page'; diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index 11263ef..48b97ea 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -1,4 +1,3 @@ -import React from "react"; import FeedList from "../components/FeedList"; import EpisodePlayer from "../components/EpisodePlayer"; diff --git a/frontend/src/components/EpisodePlayer.tsx b/frontend/src/components/EpisodePlayer.tsx index aca706c..460b6ef 100644 --- a/frontend/src/components/EpisodePlayer.tsx +++ b/frontend/src/components/EpisodePlayer.tsx @@ -1,6 +1,4 @@ -"use client"; - -import React, { useEffect, useState } from "react"; +import { useEffect, useState } from "react"; interface Episode { id: string; @@ -13,7 +11,6 @@ interface Episode { export default function EpisodePlayer() { const [episodes, setEpisodes] = useState([]); const [selectedEpisode, setSelectedEpisode] = useState(null); - const [isPlaying, setIsPlaying] = useState(false); const [audioUrl, setAudioUrl] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); diff --git a/frontend/src/components/FeedList.tsx b/frontend/src/components/FeedList.tsx index 0a22373..af8751e 100644 --- a/frontend/src/components/FeedList.tsx +++ b/frontend/src/components/FeedList.tsx @@ -1,8 +1,4 @@ -"use client"; - -"use client"; - -import React, { useEffect, useState } from "react"; +import { useEffect, useState } from "react"; interface FeedItem { id: string; diff --git a/scripts/fetch_and_generate.ts b/scripts/fetch_and_generate.ts index 0d88614..ae38509 100644 --- a/scripts/fetch_and_generate.ts +++ b/scripts/fetch_and_generate.ts @@ -29,18 +29,22 @@ async function main() { pub.getMonth() === yesterday.getMonth() && pub.getDate() === yesterday.getDate() ) { - const already = await markAsProcessed(url, item.id); + const already = await markAsProcessed(url, item['id'] as string); if (already) continue; - const scriptText = await openAI_GenerateScript(item); - const audioFilePath = await generateTTS(item.id, scriptText); + const scriptText = await openAI_GenerateScript({ + title: item.title ?? "", + link: item.link ?? "", + contentSnippet: item.contentSnippet ?? "", + }); + const audioFilePath = await generateTTS(item['id'] as string, scriptText); await saveEpisode({ - id: item.id, - title: item.title, + id: item['id'] as string, + title: item.title ?? "", pubDate: pub.toISOString(), audioPath: audioFilePath, - sourceLink: item.link, + sourceLink: item.link ?? "", }); } } diff --git a/server.ts b/server.ts index 510bae0..968045f 100644 --- a/server.ts +++ b/server.ts @@ -19,7 +19,6 @@ if (!fs.existsSync(dbPath)) { db.exec(fs.readFileSync(path.join(projectRoot, "schema.sql"), "utf-8")); // 静的ファイルパスの設定 -const frontendPublicDir = path.join(projectRoot, "frontend", "public"); const frontendBuildDir = path.join(projectRoot, "frontend", "dist"); const podcastAudioDir = path.join(projectRoot, "static", "podcast_audio"); const generalPublicDir = path.join(projectRoot, "public"); @@ -71,7 +70,8 @@ app.get("/assets/*", async (c) => { : filePath.endsWith(".css") ? "text/css" : "application/octet-stream"; - return c.body(file, 200, { "Content-Type": contentType }); + const blob = await file.blob(); + return c.body(blob, 200, { "Content-Type": contentType }); } return c.notFound(); }); @@ -82,7 +82,8 @@ app.get("/podcast_audio/*", async (c) => { const audioFilePath = path.join(podcastAudioDir, audioFileName); const file = Bun.file(audioFilePath); if (await file.exists()) { - return c.body(file, 200, { "Content-Type": "audio/mpeg" }); + const blob = await file.blob(); + return c.body(blob, 200, { "Content-Type": "audio/mpeg" }); } return c.notFound(); }); @@ -93,7 +94,8 @@ app.get("/podcast.xml", async (c) => { try { const file = Bun.file(filePath); if (await file.exists()) { - return c.body(file, 200, { + const blob = await file.blob(); + return c.body(blob, 200, { "Content-Type": "application/xml; charset=utf-8", }); } @@ -109,7 +111,8 @@ app.get("/", async (c) => { const file = Bun.file(indexPath); if (await file.exists()) { console.log(`Serving index.html from ${indexPath}`); - return c.body(file, 200, { "Content-Type": "text/html; charset=utf-8" }); + const blob = await file.blob(); + return c.body(blob, 200, { "Content-Type": "text/html; charset=utf-8" }); } console.error(`index.html not found at ${indexPath}`); return c.notFound(); @@ -121,7 +124,8 @@ app.get("/index.html", async (c) => { const file = Bun.file(indexPath); if (await file.exists()) { console.log(`Serving index.html from ${indexPath}`); - return c.body(file, 200, { "Content-Type": "text/html; charset=utf-8" }); + const blob = await file.blob(); + return c.body(blob, 200, { "Content-Type": "text/html; charset=utf-8" }); } console.error(`index.html not found at ${indexPath}`); return c.notFound(); @@ -133,7 +137,8 @@ app.get("*", async (c) => { const file = Bun.file(indexPath); if (await file.exists()) { console.log(`Serving index.html from ${indexPath}`); - return c.body(file, 200, { "Content-Type": "text/html; charset=utf-8" }); + const blob = await file.blob(); + return c.body(blob, 200, { "Content-Type": "text/html; charset=utf-8" }); } console.error(`index.html not found at ${indexPath}`); return c.notFound(); diff --git a/services/database.ts b/services/database.ts index c94ed3d..fe22642 100644 --- a/services/database.ts +++ b/services/database.ts @@ -53,5 +53,5 @@ export async function saveEpisode(ep: Episode): Promise { export async function fetchAllEpisodes(): Promise { const stmt = db.prepare("SELECT * FROM episodes ORDER BY pubDate DESC"); - return stmt.all(); + return stmt.all() as Episode[]; }