-
-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2518a99
commit 4c901d0
Showing
15 changed files
with
134 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,16 @@ | ||
{ | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": "./tsconfig.json", | ||
"ecmaFeatures": { | ||
"jsx": true | ||
}, | ||
"ecmaVersion": 12, | ||
"sourceType": "module" | ||
}, | ||
"extends": [ | ||
"next/core-web-vitals", | ||
"eslint:recommended", | ||
"plugin:react/recommended", | ||
"plugin:react-hooks/recommended", | ||
"plugin:@next/next/recommended", | ||
"next", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@typescript-eslint/recommended-requiring-type-checking", | ||
"prettier" | ||
] | ||
], | ||
"ignorePatterns": ["postcss.config.js"], | ||
"rules": { | ||
"no-redeclare": "off", | ||
"@next/next/no-html-link-for-pages": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { authHandler } from "@/lib/auth"; | ||
|
||
export { authHandler as GET, authHandler as POST } | ||
export { authHandler as GET, authHandler as POST }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,76 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
@layer base { | ||
:root { | ||
--background: 0 0% 100%; | ||
--foreground: 222.2 84% 4.9%; | ||
|
||
--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; | ||
} | ||
body { | ||
@apply bg-background text-foreground; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ | |
"components": "@/components", | ||
"utils": "@/lib/utils" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
function buildAuthentikConfig() { | ||
let {id, secret, issuer} = process.env; | ||
let { id, secret, issuer } = process.env; | ||
if (!id || !secret || !issuer) { | ||
return undefined; | ||
} | ||
|
||
return { | ||
clientId: id, | ||
clientSecret: secret, | ||
issuer: issuer, | ||
}; | ||
clientId: id, | ||
clientSecret: secret, | ||
issuer: issuer, | ||
}; | ||
} | ||
|
||
const serverConfig = { | ||
auth: { | ||
authentik: buildAuthentikConfig(), | ||
} | ||
}, | ||
}; | ||
|
||
export default serverConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { type ClassValue, clsx } from "clsx" | ||
import { twMerge } from "tailwind-merge" | ||
import { type ClassValue, clsx } from "clsx"; | ||
import { twMerge } from "tailwind-merge"; | ||
|
||
export function cn(...inputs: ClassValue[]) { | ||
return twMerge(clsx(inputs)) | ||
return twMerge(clsx(inputs)); | ||
} |
Oops, something went wrong.