Commiting to switch to a different orm
This commit is contained in:
@@ -1,23 +1,24 @@
|
||||
import { signIn } from "@/lib/auth"
|
||||
import { signIn } from "@/lib/auth";
|
||||
import type React from "react";
|
||||
|
||||
export default function Auth(props: {
|
||||
searchParams: { callbackUrl: string | undefined }
|
||||
}) {
|
||||
searchParams: Promise<{ callbackUrl: string | undefined }>
|
||||
}): React.JSX.Element {
|
||||
return (
|
||||
<form
|
||||
className="w-40 mx-auto"
|
||||
action={async () => {
|
||||
"use server"
|
||||
"use server";
|
||||
await signIn("authelia", {
|
||||
redirectTo: props.searchParams?.callbackUrl ?? "",
|
||||
})
|
||||
redirectTo: (await props.searchParams)?.callbackUrl ?? "",
|
||||
});
|
||||
}}
|
||||
>
|
||||
>
|
||||
<button type="submit"
|
||||
className={`rounded-lg dark:bg-dracula-bg-light transition-colors duration-100 dark:text-white px-2 py-2 font-normal border-transparent`}
|
||||
>
|
||||
<span>Sign in with Authelia</span>
|
||||
</button>
|
||||
</form>
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
import { SessionProvider } from "next-auth/react";
|
||||
|
||||
import NavBar from '@/components/navbar';
|
||||
import Footer from '@/components/footer';
|
||||
import LogIn from "@/components/auth/login";
|
||||
|
||||
import "../globals.css";
|
||||
|
||||
|
||||
@@ -11,21 +11,23 @@ export default async function Photos(): Promise<React.JSX.Element> {
|
||||
const {data: imageData} = await getImageData();
|
||||
|
||||
return (
|
||||
<Lightbox imageData={imageData.images}>
|
||||
{imageData.images.map((image) => (
|
||||
<Image
|
||||
key={image.src}
|
||||
alt={image.src}
|
||||
src={image.src}
|
||||
className="object-contain h-60 w-80"
|
||||
sizes="100vw"
|
||||
loading="lazy"
|
||||
width={image.width}
|
||||
height={image.height}
|
||||
blurDataURL={image.blur}
|
||||
placeholder="blur"
|
||||
/>
|
||||
))}
|
||||
</Lightbox>
|
||||
<div className="mx-auto">
|
||||
<Lightbox imageData={imageData.images}>
|
||||
{imageData.images.map((image) => (
|
||||
<Image
|
||||
key={image.src}
|
||||
alt={image.src}
|
||||
src={image.src}
|
||||
className="object-contain h-60 w-80"
|
||||
sizes="100vw"
|
||||
loading="lazy"
|
||||
width={image.width}
|
||||
height={image.height}
|
||||
blurDataURL={image.blur}
|
||||
placeholder="blur"
|
||||
/>
|
||||
))}
|
||||
</Lightbox>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,9 +15,12 @@ export async function generateStaticParams(): Promise<{slug: string[]}[]> {
|
||||
return slugs;
|
||||
}
|
||||
|
||||
export default async function Post({params}: {params: { slug: string[] }}): Promise<React.JSX.Element> {
|
||||
const mdxFile = await import(`../../../../markdown/posts/[...slug]/${params.slug.join('/')}.mdx`)
|
||||
const Post = dynamic(async () => mdxFile);
|
||||
export default async function Post({params}: {params: Promise<{ slug: string[] }>}): Promise<React.JSX.Element> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const mdxFile = await import(`../../../../markdown/posts/[...slug]/${(await params).slug.join('/')}.mdx`);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-return
|
||||
const Post = dynamic(() => mdxFile);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return (
|
||||
<Post/>
|
||||
);
|
||||
|
||||
@@ -21,12 +21,15 @@ async function loadPostDetails(): Promise<postDetails[]> {
|
||||
});
|
||||
|
||||
const loadPostData = posts.map(async (post) => {
|
||||
const slug = [post.split('/').at(-1)!.slice(0, -4)]
|
||||
const mdxFile = await import(`../../../../src/markdown/posts/[...slug]/${slug.join('/')}.mdx`)
|
||||
const slug = [post.split('/').at(-1)!.slice(0, -4)];
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const mdxFile = await import(`../../../../src/markdown/posts/[...slug]/${slug.join('/')}.mdx`);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
return {
|
||||
link: getCurrentUrl() + '/posts/' + slug.join('/'),
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
|
||||
metadata: mdxFile.metadata,
|
||||
link: getCurrentUrl() + '/posts/' + slug.join('/')
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
const postData = await Promise.all(loadPostData);
|
||||
@@ -39,7 +42,7 @@ const getPosts = unstable_cache(
|
||||
{
|
||||
revalidate: false
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
export default async function Posts(): Promise<React.JSX.Element> {
|
||||
const postDetails = await getPosts();
|
||||
@@ -58,7 +61,7 @@ export default async function Posts(): Promise<React.JSX.Element> {
|
||||
<div key={`${post.link}_${tag}`}>
|
||||
<span className="select-none text-sm me-2 px-2.5 py-1 rounded border border-dracula-pink dark:bg-dracula-bg-darker dark:text-dracula-pink">{tag}</span>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<p>
|
||||
@@ -66,7 +69,7 @@ export default async function Posts(): Promise<React.JSX.Element> {
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -2,21 +2,21 @@ import { NextRequest } from "next/server";
|
||||
import { handlers } from "@/lib/auth";
|
||||
|
||||
const reqWithTrustedOrigin = (req: NextRequest): NextRequest => {
|
||||
const proto = req.headers.get('x-forwarded-proto')
|
||||
const host = req.headers.get('x-forwarded-host')
|
||||
const proto = req.headers.get('x-forwarded-proto');
|
||||
const host = req.headers.get('x-forwarded-host');
|
||||
if (!proto || !host) {
|
||||
console.warn("Missing x-forwarded-proto or x-forwarded-host headers.")
|
||||
return req
|
||||
console.warn("Missing x-forwarded-proto or x-forwarded-host headers.");
|
||||
return req;
|
||||
}
|
||||
const envOrigin = `${proto}://${host}`
|
||||
const { href, origin } = req.nextUrl
|
||||
return new NextRequest(href.replace(origin, envOrigin), req)
|
||||
}
|
||||
const envOrigin = `${proto}://${host}`;
|
||||
const { href, origin } = req.nextUrl;
|
||||
return new NextRequest(href.replace(origin, envOrigin), req);
|
||||
};
|
||||
|
||||
export const GET = (req: NextRequest) => {
|
||||
return handlers.GET(reqWithTrustedOrigin(req))
|
||||
}
|
||||
export const GET = (req: NextRequest): Promise<Response> => {
|
||||
return handlers.GET(reqWithTrustedOrigin(req));
|
||||
};
|
||||
|
||||
export const POST = (req: NextRequest) => {
|
||||
return handlers.POST(reqWithTrustedOrigin(req))
|
||||
}
|
||||
export const POST = (req: NextRequest): Promise<Response> => {
|
||||
return handlers.POST(reqWithTrustedOrigin(req));
|
||||
};
|
||||
@@ -49,8 +49,8 @@ export async function GET(): Promise<Response> {
|
||||
}),
|
||||
title: photo.title ?? undefined,
|
||||
description: photo.description ?? undefined
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
return NextResponse.json<GetPhotos>({ status: 200, data: { images } });
|
||||
}
|
||||
@@ -15,7 +15,7 @@ export type GetPhotosUpdate = {
|
||||
|
||||
export const GET = auth(async function GET(req): Promise<Response> {
|
||||
if (!req.auth) {
|
||||
return NextResponse.json({ message: "Not authenticated" }, { status: 401 })
|
||||
return NextResponse.json({ message: "Not authenticated" }, { status: 401 });
|
||||
}
|
||||
|
||||
const dataSource = await PhotoDataSource.dataSource;
|
||||
@@ -35,7 +35,7 @@ export const GET = auth(async function GET(req): Promise<Response> {
|
||||
const s3Res = await s3Client.send(listObjCmd);
|
||||
|
||||
if (!s3Res.Contents) {
|
||||
return NextResponse.json({ status: 500 })
|
||||
return NextResponse.json({ status: 500 });
|
||||
}
|
||||
const s3Photos = sift(s3Res.Contents.map((obj) => {
|
||||
if (!obj.Key?.endsWith('/')) {
|
||||
@@ -51,7 +51,7 @@ export const GET = auth(async function GET(req): Promise<Response> {
|
||||
const getImageCmd = new GetObjectCommand({
|
||||
Bucket: "joemonk-photos",
|
||||
Key: fileName.replace("https://fly.storage.tigris.dev/joemonk-photos/", "")
|
||||
})
|
||||
});
|
||||
const imgRes = await s3Client.send(getImageCmd);
|
||||
const image = await imgRes.Body?.transformToByteArray();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user