add radio page

This commit is contained in:
Alex Frantz
2024-04-22 02:03:14 -04:00
parent dd60999e3a
commit 50f793de74
8 changed files with 142 additions and 16 deletions
+3 -1
View File
@@ -1,6 +1,7 @@
import { postRouter } from "@/server/api/routers/post";
import { linksRouter } from "./routers/links";
import { blogRouter } from "./routers/blog";
import { miscRouter } from "./routers/misc";
import { createTRPCRouter } from "@/server/api/trpc";
/**
@@ -11,7 +12,8 @@ import { createTRPCRouter } from "@/server/api/trpc";
export const appRouter = createTRPCRouter({
post: postRouter,
links: linksRouter,
blog: blogRouter
blog: blogRouter,
misc: miscRouter
});
// export type definition of API
+44
View File
@@ -0,0 +1,44 @@
import axios from 'axios';
import {
createTRPCRouter,
publicProcedure
} from '@/server/api/trpc';
type ImageListType = {
"size": string,
"#text": string
}
type TrackResponseType = {
status: number,
data: {
tracks: LastTrackType[]
}
}
type LastTrackType = {
"@attr": {
"nowplaying": string
},
"album": {
"mbid": string,
"#text": string
},
"artist": {
"mbid": string,
"#text": string,
},
"image": ImageListType[],
"mbid": string,
"name": string,
"streamable": number,
"url": string
}
export const miscRouter = createTRPCRouter({
song: publicProcedure
.query(async () => {
const response = await axios.get<TrackResponseType>("https://api.thatalex.dev/v4/social/music")
return response.data
}),
})