Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next.js 15 #10

Merged
merged 21 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
bun run build 2>&1 | tee -a build.log
env:
STANDALONE: "1"
# TURBOPACK_BUILD: 1
# TURBOPACK: 1
# TURBO: 1

DATABASE_URL: "libsql://void.riskymh.dev"
EMAIL_AUTH_TOKEN: "no"
Expand Down
2 changes: 1 addition & 1 deletion app/(auth)/api/invite/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function GET() {

if (!user) {
// scamful way of getting bot :)
if (process.env.SECRET_SPECIAL_TOKEN_YAY !== headers().get("Authorization")) {
if (process.env.SECRET_SPECIAL_TOKEN_YAY !== (await headers()).get("Authorization")) {
return new Response("Unauthorized", { status: 401 });
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/(auth)/login/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ async function handleUserRedirection(
columns: { mailboxId: true },
});

const possibleMailbox = cookies().get("mailboxId")?.value;
const possibleMailbox = (await cookies()).get("mailboxId")?.value;
const mailboxIdAllowed = mailboxes.some(({ mailboxId }) => mailboxId === possibleMailbox);

if (!(possibleMailbox && mailboxIdAllowed)) {
cookies().set("mailboxId", mailboxes[0].mailboxId, {
(await cookies()).set("mailboxId", mailboxes[0].mailboxId, {
path: "/",
expires: new Date("2038-01-19 04:14:07"),
});
Expand All @@ -134,7 +134,7 @@ async function handleUserRedirection(
}

// maybe ?from=/...
const referer = headers().get("referer");
const referer = (await headers()).get("referer");
if (referer) {
// biome-ignore lint: i lazy
callback = new URL(referer).searchParams?.get("from");
Expand Down
4 changes: 3 additions & 1 deletion app/(auth)/login/reset/form.client.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import DisableFormReset from "@/components/disable-reset.client";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
Expand Down Expand Up @@ -32,7 +33,7 @@ export function UserAuthForm({ className, username, token, ...props }: UserAuthF
return (
<>
<div className={cn("grid gap-6", className)} {...props}>
<form action={onSubmit} className="grid gap-2">
<form action={onSubmit} className="grid gap-2" id="reset-pwd-form">
<div className="grid gap-1">
<Label className="sr-only" htmlFor="email">
Username
Expand Down Expand Up @@ -70,6 +71,7 @@ export function UserAuthForm({ className, username, token, ...props }: UserAuthF
{isPending && <Loader2 className="me-2 size-4 animate-spin" />}
Sign In
</Button>
<DisableFormReset formId="reset-pwd-form" />
</form>
</div>
</>
Expand Down
11 changes: 5 additions & 6 deletions app/(auth)/login/reset/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ import Link from "next/link";
import { notFound } from "next/navigation";
import { UserAuthForm } from "./form.client";

export const revalidate = 0;
export const dynamic = "force-static";

export default async function LoginPage({
searchParams,
}: {
searchParams: {
export default async function LoginPage(props: {
searchParams: Promise<{
token: string;
};
}>;
}) {
const searchParams = await props.searchParams;
if (!searchParams.token) return notFound();

const token = await db.query.ResetPasswordToken.findFirst({
Expand Down
4 changes: 2 additions & 2 deletions app/(auth)/register/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default async function signUp(
}

// currently you require invite code to sign up
const referer = headers().get("referer");
const referer = (await headers()).get("referer");
if (!referer) return noInvite;
const inviteCode = new URL(referer).searchParams?.get("invite");
if (!inviteCode) return noInvite;
Expand Down Expand Up @@ -111,7 +111,7 @@ export default async function signUp(

// add user token to cookie
await addUserTokenToCookie({ id: userId });
cookies().set("mailboxId", mailboxId, {
(await cookies()).set("mailboxId", mailboxId, {
path: "/",
expires: new Date("2038-01-19 04:14:07"),
});
Expand Down
1 change: 1 addition & 0 deletions app/(auth)/register/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { UserAuthForm } from "./form.client";

// todo: maybe re-enable edge
// export const runtime = "edge";
export const dynamic = "force-static";

export default async function LoginPage() {
return (
Expand Down
15 changes: 7 additions & 8 deletions app/(email)/mail/[mailbox]/(email-list)/drafts/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ export const metadata = {
title: "Drafts",
} as Metadata;

export default async function Mailbox({
params,
searchParams,
}: {
params: {
export default async function Mailbox(props: {
params: Promise<{
mailbox: string;
};
searchParams: {
}>;
searchParams: Promise<{
take?: string;
q?: string;
};
}>;
}) {
const searchParams = await props.searchParams;
const params = await props.params;
await pageMailboxAccess(params.mailbox);

return (
Expand Down
1 change: 1 addition & 0 deletions app/(email)/mail/[mailbox]/(email-list)/email-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { formatTimeAgo } from "@/utils/tools";
import { cn } from "@/utils/tw";
import { eq } from "drizzle-orm";
import Link from "next/link";
import type { JSX } from "react";
import { RefreshButton } from "../components.client";
import { mailboxCategories, userMailboxAccess } from "../tools";
import { EmailItem } from "./email-item";
Expand Down
15 changes: 7 additions & 8 deletions app/(email)/mail/[mailbox]/(email-list)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ export const metadata = {
title: "Inbox",
} as Metadata;

export default async function Mailbox({
params,
searchParams,
}: {
params: {
export default async function Mailbox(props: {
params: Promise<{
mailbox: string;
};
searchParams?: {
}>;
searchParams?: Promise<{
category?: string;
take?: string;
q?: string;
};
}>;
}) {
const searchParams = await props.searchParams;
const params = await props.params;
return (
<EmailList
mailboxId={params.mailbox}
Expand Down
15 changes: 7 additions & 8 deletions app/(email)/mail/[mailbox]/(email-list)/sent/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ export const metadata = {
title: "Sent",
} as Metadata;

export default async function Mailbox({
params,
searchParams,
}: {
params: {
export default async function Mailbox(props: {
params: Promise<{
mailbox: string;
};
searchParams?: {
}>;
searchParams?: Promise<{
category?: string;
take?: string;
q?: string;
};
}>;
}) {
const searchParams = await props.searchParams;
const params = await props.params;
await pageMailboxAccess(params.mailbox);

return (
Expand Down
15 changes: 7 additions & 8 deletions app/(email)/mail/[mailbox]/(email-list)/starred/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ export const metadata = {
title: "Starred",
} as Metadata;

export default async function Mailbox({
params,
searchParams,
}: {
params: {
export default async function Mailbox(props: {
params: Promise<{
mailbox: string;
};
searchParams?: {
}>;
searchParams?: Promise<{
category?: string;
take?: string;
q?: string;
};
}>;
}) {
const searchParams = await props.searchParams;
const params = await props.params;
await pageMailboxAccess(params.mailbox);

return (
Expand Down
15 changes: 7 additions & 8 deletions app/(email)/mail/[mailbox]/(email-list)/temp/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ export const metadata = {
title: "Temporary Email",
} as Metadata;

export default async function Mailbox({
params,
searchParams,
}: {
params: {
export default async function Mailbox(props: {
params: Promise<{
mailbox: string;
};
searchParams?: {
}>;
searchParams?: Promise<{
category?: string;
take?: string;
q?: string;
};
}>;
}) {
const searchParams = await props.searchParams;
const params = await props.params;
await pageMailboxAccess(params.mailbox);

return (
Expand Down
15 changes: 7 additions & 8 deletions app/(email)/mail/[mailbox]/(email-list)/trash/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ export const metadata = {
title: "Trash",
} as Metadata;

export default async function Mailbox({
params,
searchParams,
}: {
params: {
export default async function Mailbox(props: {
params: Promise<{
mailbox: string;
};
searchParams?: {
}>;
searchParams?: Promise<{
category?: string;
take?: string;
q?: string;
};
}>;
}) {
const searchParams = await props.searchParams;
const params = await props.params;
await pageMailboxAccess(params.mailbox);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ import { userMailboxAccess } from "../../../tools";

export async function GET(
request: Request,
{
params,
}: {
params: {
props: {
params: Promise<{
mailbox: string;
email: string;
attachment: string;
};
}>;
},
) {
const params = await props.params;
const userId = await getCurrentUser();
if (!(userId && (await userMailboxAccess(params.mailbox, userId)))) return notFound();

Expand Down
9 changes: 4 additions & 5 deletions app/(email)/mail/[mailbox]/[email]/email.eml/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ import { userMailboxAccess } from "../../tools";

export async function GET(
request: Request,
{
params,
}: {
params: {
props: {
params: Promise<{
mailbox: string;
email: string;
};
}>;
},
) {
const params = await props.params;
const userId = await getCurrentUser();
if (!(userId && (await userMailboxAccess(params.mailbox, userId)))) return notFound();

Expand Down
9 changes: 4 additions & 5 deletions app/(email)/mail/[mailbox]/[email]/email.html/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import { userMailboxAccess } from "../../tools";

export async function GET(
request: Request,
{
params,
}: {
params: {
props: {
params: Promise<{
mailbox: string;
email: string;
};
}>;
},
) {
const params = await props.params;
const userId = await getCurrentUser();
if (!(userId && (await userMailboxAccess(params.mailbox, userId)))) return notFound();

Expand Down
9 changes: 4 additions & 5 deletions app/(email)/mail/[mailbox]/[email]/email.txt/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import { userMailboxAccess } from "../../tools";

export async function GET(
request: Request,
{
params,
}: {
params: {
props: {
params: Promise<{
mailbox: string;
email: string;
};
}>;
},
) {
const params = await props.params;
const userId = await getCurrentUser();
if (!(userId && (await userMailboxAccess(params.mailbox, userId)))) return notFound();

Expand Down
Loading
Loading