Skip to content

Commit

Permalink
Merge pull request #62 from ajcwebdev/astro
Browse files Browse the repository at this point in the history
Finish Migrating React Code to Astro
  • Loading branch information
ajcwebdev authored Dec 9, 2024
2 parents 1d16c24 + 0c1f95f commit c8dd753
Show file tree
Hide file tree
Showing 48 changed files with 558 additions and 287 deletions.
153 changes: 0 additions & 153 deletions packages/astro/src/styles/form.css

This file was deleted.

11 changes: 0 additions & 11 deletions packages/astro/src/styles/global.css

This file was deleted.

4 changes: 2 additions & 2 deletions src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { handleFileRequest } from './routes/file'
import { handleRSSRequest } from './routes/rss'
import { l } from '../../src/utils/logging'
import { env } from 'node:process'
import { getShowNotes } from './routes/showNotes'
import { getShowNote } from './routes/showNote'
import { getShowNotes } from './routes/show-notes'
import { getShowNote } from './routes/show-note'

// Set the port from environment variable or default to 3000
// const port = Number(env.PORT) || 3000
Expand Down
9 changes: 7 additions & 2 deletions src/server/routes/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

import type { FastifyRequest, FastifyReply } from 'fastify'
import { processFile } from '../../commands/process-file'
import { reqToOpts } from '../utils/reqToOpts'
import { reqToOpts } from '../utils/req-to-opts'
import { l, err } from '../../../src/utils/logging'

// Define a type for the request body
interface FileRequestBody {
filePath?: string
}

// Handler for the /file route
export const handleFileRequest = async (
request: FastifyRequest,
Expand All @@ -14,7 +19,7 @@ export const handleFileRequest = async (

try {
// Access parsed request body
const requestData = request.body as any
const requestData = request.body as FileRequestBody
l('\nParsed request body:', requestData)

// Extract file path from the request data
Expand Down
8 changes: 6 additions & 2 deletions src/server/routes/playlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import type { FastifyRequest, FastifyReply } from 'fastify'
import { processPlaylist } from '../../commands/process-playlist'
import { reqToOpts } from '../utils/reqToOpts'
import { reqToOpts } from '../utils/req-to-opts'
import { l, err } from '../../../src/utils/logging'

interface PlaylistRequestBody {
playlistUrl?: string
}

// Handler for the /playlist route
export const handlePlaylistRequest = async (
request: FastifyRequest,
Expand All @@ -14,7 +18,7 @@ export const handlePlaylistRequest = async (

try {
// Access parsed request body
const requestData = request.body as any
const requestData = request.body as PlaylistRequestBody
l('\nParsed request body:', requestData)

// Extract playlist URL from the request data
Expand Down
8 changes: 6 additions & 2 deletions src/server/routes/rss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import type { FastifyRequest, FastifyReply } from 'fastify'
import { processRSS } from '../../commands/process-rss'
import { reqToOpts } from '../utils/reqToOpts'
import { reqToOpts } from '../utils/req-to-opts'
import { l, err } from '../../../src/utils/logging'

interface RSSRequestBody {
rssUrl?: string
}

// Handler for the /rss route
export const handleRSSRequest = async (
request: FastifyRequest,
Expand All @@ -14,7 +18,7 @@ export const handleRSSRequest = async (

try {
// Access parsed request body
const requestData = request.body as any
const requestData = request.body as RSSRequestBody
l('\nParsed request body:', requestData)

// Extract RSS URL from the request data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// packages/server/routes/showNote.ts
// src/server/routes/show-note.ts

import { db } from '../db'
import type { FastifyRequest, FastifyReply } from 'fastify'

export const getShowNote = async (request: any, reply: any) => {
export const getShowNote = async (request: FastifyRequest, reply: FastifyReply) => {
try {
const { id } = request.params
const { id } = request.params as { id: string }
// Fetch the show note from the database
const showNote = db.prepare(`SELECT * FROM show_notes WHERE id = ?`).get(id)
if (showNote) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// packages/server/routes/showNotes.ts
// src/server/routes/show-notes.ts

import { db } from '../db'
import type { FastifyRequest, FastifyReply } from 'fastify'

export const getShowNotes = async (reply: any) => {
export const getShowNotes = async (_request: FastifyRequest, reply: FastifyReply) => {
try {
// Fetch all show notes from the database
const showNotes = db.prepare(`SELECT * FROM show_notes ORDER BY date DESC`).all()
Expand Down
10 changes: 7 additions & 3 deletions src/server/routes/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import type { FastifyRequest, FastifyReply } from 'fastify'
import { processURLs } from '../../commands/process-urls'
import { reqToOpts } from '../utils/reqToOpts'
import { reqToOpts } from '../utils/req-to-opts'
import { l, err } from '../../../src/utils/logging'

interface URLsRequestBody {
filePath?: string
}

// Handler for the /urls route
export const handleURLsRequest = async (
request: FastifyRequest,
Expand All @@ -14,11 +18,11 @@ export const handleURLsRequest = async (

try {
// Access parsed request body
const requestData = request.body as any
const requestData = request.body
l('\nParsed request body:', requestData)

// Extract file path from the request data
const { filePath } = requestData
const { filePath } = requestData as URLsRequestBody

if (!filePath) {
l('File path not provided, sending 400')
Expand Down
8 changes: 6 additions & 2 deletions src/server/routes/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import type { FastifyRequest, FastifyReply } from 'fastify'
import { processVideo } from '../../commands/process-video'
import { reqToOpts } from '../utils/reqToOpts'
import { reqToOpts } from '../utils/req-to-opts'
import { l, err } from '../../../src/utils/logging'

interface VideoRequestBody {
youtubeUrl?: string
}

// Handler for the /video route
export const handleVideoRequest = async (
request: FastifyRequest,
Expand All @@ -14,7 +18,7 @@ export const handleVideoRequest = async (

try {
// Access parsed request body
const requestData = request.body as any
const requestData = request.body as VideoRequestBody
l('\nParsed request body:', requestData)

// Extract YouTube URL from the request data
Expand Down
2 changes: 1 addition & 1 deletion src/server/tests/fetch-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ const requests = [
},
]

const fetchRequest = async (request: any, index: any) => {
const fetchRequest = async (request, index) => {
try {
// Get list of files before the request
const filesBefore = await fs.readdir(OUTPUT_DIR)
Expand Down
4 changes: 2 additions & 2 deletions src/server/tests/fetch-local.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// packages/server/tests/fetch-local.ts
// src/server/tests/fetch-local.ts

import fs from 'fs/promises'
import path from 'path'
Expand Down Expand Up @@ -211,7 +211,7 @@ const requests = [
},
]

const fetchRequest = async (request: any, index: any) => {
const fetchRequest = async (request, index) => {
try {
// Get list of files before the request
const filesBefore = await fs.readdir(OUTPUT_DIR)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// src/server/utils/reqToOpts.ts
// src/server/utils/req-to-opts.ts

import type { ProcessingOptions, LLMServices } from '../../../src/types/main'
import type { TranscriptServices } from '../../../src/types/transcript-service-types'
import type { ProcessingOptions, LLMServices } from '../../types/main'
import type { TranscriptServices } from '../../types/transcript-service-types'

// Function to map request data to processing options
export function reqToOpts(requestData: any): {
Expand Down
4 changes: 2 additions & 2 deletions src/types/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type ProcessingOptions = {
file?: string

/** URL of the podcast RSS feed to process. */
rss?: string[]
rss?: string | string[]

/** Specific items (audio URLs) from the RSS feed to process. */
item?: string[]
Expand Down Expand Up @@ -133,7 +133,7 @@ export type InquirerAnswers = {
file?: string

/** RSS feed URL provided by the user. */
rss?: string
rss?: string | string[]

/** Whether the user wants to specify specific RSS items. */
specifyItem?: boolean
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions packages/astro/astro.config.ts → web/astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { expressiveCodeOptions } from "./src/site.config"

// https://astro.build/config
export default defineConfig({
output: "server",
site: "https://autoshow.sh/",
integrations: [
expressiveCode(expressiveCodeOptions),
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
// web/src/components/BaseHead.astro
import type { SiteMeta } from "@/types"
import { siteConfig } from "@/site-config"
import "../styles/global.css"
Expand Down
Loading

0 comments on commit c8dd753

Please sign in to comment.