aboutsummaryrefslogtreecommitdiffstats
path: root/web/app
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-02-06 13:12:21 +0000
committerMohamedBassem <me@mbassem.com>2024-02-06 13:12:21 +0000
commit4c901d073376ab9fd37284801011a12261d5963d (patch)
tree537eaea0b85c057dd1b7490afe755c634febece0 /web/app
parent2518a99d1c296dc838edc2330dc6eb6fe5aead8e (diff)
downloadkarakeep-4c901d073376ab9fd37284801011a12261d5963d.tar.zst
Linting and formatting
Diffstat (limited to 'web/app')
-rw-r--r--web/app/api/auth/[...nextauth]/route.tsx2
-rw-r--r--web/app/api/v1/links/route.ts105
-rw-r--r--web/app/globals.css38
-rw-r--r--web/app/layout.tsx1
4 files changed, 77 insertions, 69 deletions
diff --git a/web/app/api/auth/[...nextauth]/route.tsx b/web/app/api/auth/[...nextauth]/route.tsx
index bfcda516..e722926b 100644
--- a/web/app/api/auth/[...nextauth]/route.tsx
+++ b/web/app/api/auth/[...nextauth]/route.tsx
@@ -1,3 +1,3 @@
import { authHandler } from "@/lib/auth";
-export { authHandler as GET, authHandler as POST }
+export { authHandler as GET, authHandler as POST };
diff --git a/web/app/api/v1/links/route.ts b/web/app/api/v1/links/route.ts
index 5be1018e..97bfa3de 100644
--- a/web/app/api/v1/links/route.ts
+++ b/web/app/api/v1/links/route.ts
@@ -1,60 +1,67 @@
import { authOptions } from "@/lib/auth";
import prisma from "@/lib/prisma";
-import { ZNewBookmarkedLinkRequest, ZGetLinksResponse, ZBookmarkedLink } from "@/lib/types/api/links";
+import {
+ ZNewBookmarkedLinkRequest,
+ ZGetLinksResponse,
+ ZBookmarkedLink,
+} from "@/lib/types/api/links";
import { getServerSession } from "next-auth";
import { NextRequest, NextResponse } from "next/server";
export async function POST(request: NextRequest) {
- // TODO: We probably should be using an API key here instead of the session;
- const session = await getServerSession(authOptions);
- if (!session) {
- return new Response(null, { status: 401 });
- }
-
- const linkRequest = ZNewBookmarkedLinkRequest.safeParse(await request.json());
-
- if (!linkRequest.success) {
- return NextResponse.json({
- error: linkRequest.error.toString(),
- }, { status: 400 });
- }
-
- const link = await prisma.bookmarkedLink.create({
- data: {
- url: linkRequest.data.url,
- userId: session.user.id,
- }
- });
-
- let response: ZBookmarkedLink = { ...link };
-
- return NextResponse.json(response, { status: 201 });
+ // TODO: We probably should be using an API key here instead of the session;
+ const session = await getServerSession(authOptions);
+ if (!session) {
+ return new Response(null, { status: 401 });
+ }
+
+ const linkRequest = ZNewBookmarkedLinkRequest.safeParse(await request.json());
+
+ if (!linkRequest.success) {
+ return NextResponse.json(
+ {
+ error: linkRequest.error.toString(),
+ },
+ { status: 400 },
+ );
+ }
+
+ const link = await prisma.bookmarkedLink.create({
+ data: {
+ url: linkRequest.data.url,
+ userId: session.user.id,
+ },
+ });
+
+ let response: ZBookmarkedLink = { ...link };
+
+ return NextResponse.json(response, { status: 201 });
}
export async function GET() {
- // TODO: We probably should be using an API key here instead of the session;
- const session = await getServerSession(authOptions);
- if (!session) {
- return new Response(null, { status: 401 });
- }
- const links = await prisma.bookmarkedLink.findMany({
- where: {
- userId: session.user.id,
- },
+ // TODO: We probably should be using an API key here instead of the session;
+ const session = await getServerSession(authOptions);
+ if (!session) {
+ return new Response(null, { status: 401 });
+ }
+ const links = await prisma.bookmarkedLink.findMany({
+ where: {
+ userId: session.user.id,
+ },
+ select: {
+ id: true,
+ url: true,
+ createdAt: true,
+ details: {
select: {
- id: true,
- url: true,
- createdAt: true,
- details: {
- select: {
- title: true,
- description: true,
- imageUrl: true,
- }
- },
- }
- });
-
- let response: ZGetLinksResponse = { links };
- return NextResponse.json(response);
+ title: true,
+ description: true,
+ imageUrl: true,
+ },
+ },
+ },
+ });
+
+ let response: ZGetLinksResponse = { links };
+ return NextResponse.json(response);
}
diff --git a/web/app/globals.css b/web/app/globals.css
index 6a757250..8abdb15c 100644
--- a/web/app/globals.css
+++ b/web/app/globals.css
@@ -1,7 +1,7 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
-
+
@layer base {
:root {
--background: 0 0% 100%;
@@ -9,63 +9,63 @@
--card: 0 0% 100%;
--card-foreground: 222.2 84% 4.9%;
-
+
--popover: 0 0% 100%;
--popover-foreground: 222.2 84% 4.9%;
-
+
--primary: 222.2 47.4% 11.2%;
--primary-foreground: 210 40% 98%;
-
+
--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;
-
+
--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;
-
+
--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;
-
+
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 40% 98%;
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 222.2 84% 4.9%;
-
+
--radius: 0.5rem;
}
-
+
.dark {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;
-
+
--card: 222.2 84% 4.9%;
--card-foreground: 210 40% 98%;
-
+
--popover: 222.2 84% 4.9%;
--popover-foreground: 210 40% 98%;
-
+
--primary: 210 40% 98%;
--primary-foreground: 222.2 47.4% 11.2%;
-
+
--secondary: 217.2 32.6% 17.5%;
--secondary-foreground: 210 40% 98%;
-
+
--muted: 217.2 32.6% 17.5%;
--muted-foreground: 215 20.2% 65.1%;
-
+
--accent: 217.2 32.6% 17.5%;
--accent-foreground: 210 40% 98%;
-
+
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 210 40% 98%;
-
+
--border: 217.2 32.6% 17.5%;
--input: 217.2 32.6% 17.5%;
--ring: 212.7 26.8% 83.9%;
}
}
-
+
@layer base {
* {
@apply border-border;
@@ -73,4 +73,4 @@
body {
@apply bg-background text-foreground;
}
-} \ No newline at end of file
+}
diff --git a/web/app/layout.tsx b/web/app/layout.tsx
index 3314e478..30d918df 100644
--- a/web/app/layout.tsx
+++ b/web/app/layout.tsx
@@ -1,6 +1,7 @@
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
+import React from "react";
const inter = Inter({ subsets: ["latin"] });