diff --git a/package.json b/package.json index d7b368e..2634b68 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,9 @@ "dev": "next dev", "build": "next build", "start": "next start", - "lint": "next lint" + "lint": "next lint", + "db:generate":"drizzle-kit generate", + "db:migrate":"drizzle-kit migrate" }, "dependencies": { "@planetscale/database": "^1.18.0", diff --git a/src/pages/api/randomQuote.ts b/src/app/api/v1/quote/random/route.ts similarity index 55% rename from src/pages/api/randomQuote.ts rename to src/app/api/v1/quote/random/route.ts index 0e4928a..5e6c843 100644 --- a/src/pages/api/randomQuote.ts +++ b/src/app/api/v1/quote/random/route.ts @@ -1,8 +1,8 @@ -import { NextApiRequest, NextApiResponse } from 'next'; -import { db } from '@/db/index'; -import { quotes } from '@/db/schema'; +import { db } from "@/db/index"; +import { quotes } from "@/db/schema"; -export default async function handler(req: NextApiRequest, res: NextApiResponse) { +export const dynamic = 'force-dynamic' // defaults to auto +export async function GET(request: Request) { try { // Fetch all quotes const allQuotes = await db.select({ @@ -14,12 +14,17 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) if (allQuotes.length > 0) { const randomIndex = Math.floor(Math.random() * allQuotes.length); const randomQuote = allQuotes[randomIndex]; - res.status(200).json(randomQuote); + + return new Response(JSON.stringify(randomQuote) ) } else { - res.status(404).json({ error: "No quotes found" }); + return new Response("Error", { + status: 403 + }) } } catch (error) { console.error("Failed to fetch quote:", error); - res.status(500).json({ error: "Failed to fetch quote" }); + return new Response("Error" , { + status: 500 + }) } -} +} \ No newline at end of file diff --git a/src/app/layout.tsx b/src/app/layout.tsx index b5a25ed..b16ff59 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -2,6 +2,8 @@ import type { Metadata } from "next"; import { Inter } from "next/font/google"; import "./globals.css"; import Header from "@/components/Header"; +import ThemeProvider from "@/lib/ThemeProvider"; +import BodyTheme from "@/components/BodyTheme"; const inter = Inter({ subsets: ["latin"] }); @@ -18,8 +20,12 @@ export default function RootLayout({ return (
-Motivational
Quotes