/** @typedef {import("fastify").FastifyInstance} FastifyInstance */ import { authMiddleware } from "../modules/middleware.js"; import { getAccessToken, getChannelInfo } from "../utils/youtube.js"; /** * * @param {FastifyInstance} fastify * @param {unknown} _ * @param {() => void} done */ export const channelRoutes = (fastify, _, done) => { fastify.register(authMiddleware); fastify.get("/", async (request, response) => { try { const access_token = await getAccessToken(fastify, request); const channel = await getChannelInfo(access_token); response.send({ success: true, channel }) } catch (e) { console.log(e); } }); done(); };