Skip to content

Commit

Permalink
Fix next-contentlayer warnings and Vercel deployment build error
Browse files Browse the repository at this point in the history
  • Loading branch information
pjborowiecki committed Nov 5, 2023
1 parent 5767d55 commit 99d765d
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 59 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ yarn-error.log*
next-env.d.ts

# certificates
certificates
certificates

# content
.contentlayer
2 changes: 1 addition & 1 deletion components.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"components": "@/components",
"utils": "@/lib/utils"
}
}
}
7 changes: 6 additions & 1 deletion next.config.js → next.config.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { withContentlayer } from "next-contentlayer"

import("./src/env.mjs")

/** @type {import("next").NextConfig} */
const nextConfig = {
reactStrictMode: true,
experimental: {
webpackBuildWorker: true,
},
images: {
remotePatterns: [
{
Expand All @@ -21,4 +26,4 @@ const nextConfig = {
},
}

module.exports = nextConfig
export default withContentlayer(nextConfig)
20 changes: 20 additions & 0 deletions src/actions/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import crypto from "crypto"
import { getUserByEmail } from "@/actions/user"
import { prisma } from "@/db"
import { env } from "@/env.mjs"
import { type User } from "@prisma/client"
import {
type CreateEmailOptions,
type CreateEmailRequestOptions,
Expand Down Expand Up @@ -72,3 +73,22 @@ export async function checkIfEmailVerified(email: string): Promise<boolean> {
throw new Error("Error checking if email verified")
}
}

export async function markEmailAsVerified(
emailVerificationToken: string
): Promise<User> {
try {
return await prisma.user.update({
where: {
emailVerificationToken,
},
data: {
emailVerified: new Date(),
emailVerificationToken: null,
},
})
} catch (error) {
console.error(error)
throw new Error("Error marking email as verified")
}
}
2 changes: 1 addition & 1 deletion src/actions/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ export async function getUserByEmailVerificationToken(
console.error(error)
throw new Error("Error getting user by email verification token")
}
}
}
1 change: 0 additions & 1 deletion src/app/(auth)/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { redirect } from "next/navigation"
import { env } from "@/env.mjs"

import { getCurrentUser } from "@/lib/auth"
import { cn } from "@/lib/utils"
import { buttonVariants } from "@/components/ui/button"
import {
Card,
Expand Down
19 changes: 4 additions & 15 deletions src/app/(auth)/signup/verify-email/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type Metadata } from "next"
import Link from "next/link"
import { redirect } from "next/navigation"
import { markEmailAsVerified } from "@/actions/email"
import { getUserByEmailVerificationToken } from "@/actions/user"
import { prisma } from "@/db"
import { env } from "@/env.mjs"

import { cn } from "@/lib/utils"
Expand All @@ -22,7 +22,7 @@ export const metadata: Metadata = {
description: "Verify your email address to continue",
}

interface VerifyEmailPageProps {
export interface VerifyEmailPageProps {
searchParams: { [key: string]: string | string[] | undefined }
}

Expand Down Expand Up @@ -63,19 +63,8 @@ export default async function VerifyEmailPage({
)
}

const updatedUser = await prisma.user.update({
where: {
emailVerificationToken,
},
data: {
emailVerified: new Date(),
emailVerificationToken: null,
},
})

if (!updatedUser) {
redirect("/signup")
}
const updatedUser = await markEmailAsVerified(emailVerificationToken)
if (!updatedUser) redirect("/signup")

return (
<div className="flex min-h-screen w-full items-center justify-center">
Expand Down
12 changes: 0 additions & 12 deletions src/components/emails/email-verification-email.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,6 @@ import { Section } from "@react-email/section"
import { Tailwind } from "@react-email/tailwind"
import { Text } from "@react-email/text"

// import {
// Body,
// Button,
// Container,
// Head,
// Html,
// Preview,
// Section,
// Tailwind,
// Text,
// } from "@react-email/components"

import { siteConfig } from "@/config/site"

interface EmailVerificationEmailProps {
Expand Down
11 changes: 0 additions & 11 deletions src/components/emails/magic-link-email.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
// import {
// Body,
// Button,
// Container,
// Head,
// Html,
// Preview,
// Section,
// Tailwind,
// Text,
// } from "@react-email/components"
import { Body } from "@react-email/body"
import { Button } from "@react-email/button"
import { Container } from "@react-email/container"
Expand Down
11 changes: 0 additions & 11 deletions src/components/emails/reset-password-email.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
import * as React from "react"
// import {
// Body,
// Button,
// Container,
// Head,
// Html,
// Preview,
// Section,
// Tailwind,
// Text,
// } from "@jsx-email/all"
import { Body } from "@react-email/body"
import { Button } from "@react-email/button"
import { Container } from "@react-email/container"
Expand Down
9 changes: 4 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@
},
"include": [
"next-env.d.ts",
"**/*.js",
"**/*.cjs",
"**/*.mjs",
"**/*.ts",
"**/*.jsx",
"**/*.tsx",
"**/*.cjs",
"**/*.mjs",
".next/types/**/*.ts",
"./contentlayer.config.js",
".contentlayer/generated"
".contentlayer/generated",
"next.config.cjs"
],
"exclude": ["node_modules"]
}

0 comments on commit 99d765d

Please sign in to comment.