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

Feature/upgrade turbo to v2 #825

Merged
merged 8 commits into from
Jul 21, 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
14 changes: 11 additions & 3 deletions apps/cms/sanity.cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
import { defineCliConfig } from "sanity/cli";
import { z } from "zod";

const projectId = z.string().parse(process.env.NEXT_PUBLIC_SANITY_PROJECT_ID);
const dataset = z.string().parse(process.env.NEXT_PUBLIC_SANITY_DATASET);
const projectId = z
.string({
message: "Environment variable NEXT_PUBLIC_SANITY_PROJECT_ID is required",
})
.parse(process.env.NEXT_PUBLIC_SANITY_PROJECT_ID);
const dataset = z
.string({
message: "Environment variable NEXT_PUBLIC_SANITY_DATASET is required",
})
.parse(process.env.NEXT_PUBLIC_SANITY_DATASET);

export default defineCliConfig({ api: { projectId, dataset } });
export default defineCliConfig({ api: { dataset, projectId } });
3 changes: 2 additions & 1 deletion apps/cms/src/config/defaultDocumentNode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Iframe } from "sanity-plugin-iframe-pane";
import type { DefaultDocumentNodeResolver } from "sanity/structure";

import { Iframe } from "sanity-plugin-iframe-pane";

export const defaultDocumentNode: DefaultDocumentNodeResolver = (
S,
{ schemaType },
Expand Down
31 changes: 16 additions & 15 deletions apps/cms/src/config/sanity.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as schemas from "@/schemas";
import { PUBLIC_SITE_URL } from "@kduprey/config";
import { visionTool } from "@sanity/vision";
import { type WorkspaceOptions, defineConfig } from "sanity";
import { structureTool } from "sanity/structure";
import { presentationTool } from "sanity/presentation";
import { PUBLIC_SITE_URL } from "@kduprey/config";
import * as schemas from "@/schemas";
import { structureTool } from "sanity/structure";

import {
deskStructure,
documentActions,
Expand All @@ -16,59 +17,59 @@ const schemaTypes = Object.values(schemas);
export const PROJECT_ID = "b6x3by70";

const defaultConfig = {
document: {
actions: documentActions,
},
plugins: [
structureTool({
structure: deskStructure,
}),
visionTool(),
],
schema: {
types: schemaTypes,
templates: schemaTemplatesFilter,
},
document: {
actions: documentActions,
types: schemaTypes,
},
};

const production: WorkspaceOptions = {
...defaultConfig,
name: "production",
title: "Haus of Web, LLC - Production",
basePath: "/production",
projectId: PROJECT_ID,
dataset: "production",
name: "production",
plugins: [
presentationTool({
resolve: { mainDocuments, locations: locate },
previewUrl: {
draftMode: {
enable: "https://kentonduprey.com/api/draft",
},
},
resolve: { locations: locate, mainDocuments },
}),
...defaultConfig.plugins,
],
projectId: PROJECT_ID,
title: "Haus of Web, LLC - Production",
};

const staging: WorkspaceOptions = {
...defaultConfig,
name: "staging",
title: "Haus of Web, LLC - Staging",
basePath: "/staging",
projectId: PROJECT_ID,
dataset: "staging",
name: "staging",
plugins: [
presentationTool({
resolve: { mainDocuments, locations: locate },
previewUrl: {
draftMode: {
enable: `${PUBLIC_SITE_URL}/api/draft`,
},
},
resolve: { locations: locate, mainDocuments },
}),
...defaultConfig.plugins,
],
projectId: PROJECT_ID,
title: "Haus of Web, LLC - Staging",
};

export default defineConfig(
Expand Down
3 changes: 3 additions & 0 deletions apps/frontend/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ module.exports = {
locales: ["en"],
defaultLocale: "en",
},
eslint: {
ignoreDuringBuilds: true,
},
async redirects() {
return [
{
Expand Down
7 changes: 3 additions & 4 deletions apps/frontend/sentry.server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
import * as Sentry from "@sentry/nextjs";

Sentry.init({
// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,

dsn: "https://[email protected]/4507523620864000",

// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,

// Uncomment the line below to enable Spotlight (https://spotlightjs.com)
// spotlight: process.env.NODE_ENV === 'development',

});
3 changes: 2 additions & 1 deletion apps/frontend/src/app/HomeLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { HomeType } from "@/sanity";
import type { EncodeDataAttributeCallback } from "@sanity/react-loader";

import { About, Contact, Hero, Navbar, Projects, Skills } from "@/components";
import type { HomeType } from "@/sanity";

interface HomeLayoutProps {
encodeDataAttribute?: EncodeDataAttributeCallback;
Expand Down
11 changes: 6 additions & 5 deletions apps/frontend/src/app/api/contact/route.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import type { NextRequest } from "next/server";

import { prisma } from "@kduprey/db";
import { NextResponse } from "next/server";
import { z } from "zod";
import { fromZodError } from "zod-validation-error";
import { prisma } from "@kduprey/db";

export const POST = async (req: NextRequest) => {
try {
const { name, email, message, age } = z
const { age, email, message, name } = z
.object({
name: z.string(),
age: z.string().optional(),
email: z.string().email(),
message: z.string(),
age: z.string().optional(),
name: z.string(),
})
.parse(await req.json());

Expand All @@ -21,9 +22,9 @@ export const POST = async (req: NextRequest) => {

const res = await prisma.contactSubmission.create({
data: {
name,
email,
message,
name,
},
});

Expand Down
8 changes: 3 additions & 5 deletions apps/frontend/src/app/api/draft/route.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// ./app/api/draft/route.ts

import { client, token } from "@/sanity";
import { validatePreviewUrl } from "@sanity/preview-url-secret";
import { draftMode } from "next/headers";
import { redirect } from "next/navigation";
import { client, token } from "@/sanity";

const clientWithToken = client.withConfig({ token });

export async function GET(request: Request) {
export const GET = async (request: Request) => {
const { isValid, redirectTo = "/" } = await validatePreviewUrl(
clientWithToken,
request.url,
Expand All @@ -18,4 +16,4 @@ export async function GET(request: Request) {
draftMode().enable();

redirect(redirectTo);
}
};
3 changes: 2 additions & 1 deletion apps/frontend/src/app/api/revalidate/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { revalidateSecret } from "@/sanity";
import { revalidateTag } from "next/cache";
import { type NextRequest, NextResponse } from "next/server";
import { parseBody } from "next-sanity/webhook";
Expand All @@ -10,7 +11,7 @@ export async function POST(req: NextRequest) {
try {
const { body, isValidSignature } = await parseBody<WebhookPayload>(
req,
process.env.SANITY_REVALIDATE_SECRET,
revalidateSecret,
);

if (!isValidSignature) {
Expand Down
21 changes: 14 additions & 7 deletions apps/frontend/src/app/api/stripe/billing/meter_events/route.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { trytm } from "@bdsqqq/try";
import { NextResponse, type NextRequest } from "next/server";
import { z } from "zod";
import { verify } from "jsonwebtoken";
import { stripe } from "@kduprey/config";
import { verify } from "jsonwebtoken";
import { type NextRequest, NextResponse } from "next/server";
import { z } from "zod";

const jwtPayload = z.object({
stripe_customer_id: z.string(),
event_name: z.string(),
stripe_customer_id: z.string(),
});

export const POST = async (req: NextRequest) => {
Expand All @@ -21,12 +21,19 @@ export const POST = async (req: NextRequest) => {

const token = z
.string({
required_error: "No JWT present in request",
invalid_type_error: "Invalid JWT",
required_error: "No JWT present in request",
})
.parse(authJWT.split(" ")[1]);

const payload = verify(token, z.string().parse(process.env.JWT_SECRET));
const payload = verify(
token,
z
.string({
message: "Environment variable JWT_SECRET is required",
})
.parse(process.env.JWT_SECRET),
);

const body = jwtPayload.safeParse(payload);

Expand All @@ -39,10 +46,10 @@ export const POST = async (req: NextRequest) => {
const [stripeRes, stripeErr] = await trytm(
stripe.billing.meterEvents.create({
event_name: body.data.event_name,
timestamp: Math.floor(Date.now() / 1000),
payload: {
stripe_customer_id: body.data.stripe_customer_id,
},
timestamp: Math.floor(Date.now() / 1000),
}),
);

Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/app/global-error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as Sentry from "@sentry/nextjs";
import NextError from "next/error";
import { useEffect } from "react";

const GlobalError = ({ error }: { error: Error & { digest?: string } }) => {
const GlobalError = ({ error }: { error: { digest?: string } & Error }) => {
useEffect(() => {
Sentry.captureException(error);
}, [error]);
Expand Down
74 changes: 37 additions & 37 deletions apps/frontend/src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,47 @@
@tailwind utilities;

@layer base {
h1 {
@apply text-3xl;
}
@screen md {
h1 {
@apply text-5xl;
}
}
h1 {
@apply text-3xl;
}
@screen md {
h1 {
@apply text-5xl;
}
}

h2 {
@apply text-2xl;
}
@screen md {
h2 {
@apply text-3xl;
}
}
h3 {
@apply text-xl;
}
@screen md {
h3 {
@apply text-2xl;
}
}
p {
@apply text-gray-500 dark:text-gray-200 md:text-lg;
}
button,
input[type="submit"],
input[type="reset"],
input[type="button"] {
@apply rounded bg-black py-1 px-3 uppercase text-white transition ease-in hover:bg-white hover:text-black hover:ring-1 hover:ring-black dark:border dark:border-gray-300 dark:hover:bg-white dark:hover:text-black !important;
}
h2 {
@apply text-2xl;
}
@screen md {
h2 {
@apply text-3xl;
}
}
h3 {
@apply text-xl;
}
@screen md {
h3 {
@apply text-2xl;
}
}
p {
@apply text-gray-500 dark:text-gray-200 md:text-lg;
}
button,
input[type="submit"],
input[type="reset"],
input[type="button"] {
@apply rounded bg-black py-1 px-3 uppercase text-white transition ease-in hover:bg-white hover:text-black hover:ring-1 hover:ring-black dark:border dark:border-gray-300 dark:hover:bg-white dark:hover:text-black !important;
}
}
hr {
@apply w-4/5 rounded border-t bg-gray-300 opacity-70;
@apply w-4/5 rounded border-t bg-gray-300 opacity-70;
}

@layer components {
.input {
@apply rounded border-0 bg-gray-100 transition ease-in focus:border-black focus:bg-white focus:text-black focus:outline-none focus:ring-black dark:border dark:border-gray-300 dark:bg-black dark:text-white;
}
.input {
@apply rounded border-0 bg-gray-100 transition ease-in focus:border-black focus:bg-white focus:text-black focus:outline-none focus:ring-black dark:border dark:border-gray-300 dark:bg-black dark:text-white;
}
}
8 changes: 5 additions & 3 deletions apps/frontend/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import type { Metadata } from "next";
import type { PropsWithChildren } from "react";

import { Inter } from "next/font/google";
import "./globals.css";
import { draftMode } from "next/headers";
import { VisualEditing } from "next-sanity";

import "./globals.css";

export const metadata: Metadata = {
title: "Kenton Duprey - Web Developer",
description: "Building elegant web solutions for clients and companies",
title: "Kenton Duprey - Web Developer",
};

const inter = Inter({
subsets: ["latin"],
style: ["normal"],
subsets: ["latin"],
variable: "--font-raleway",
});

Expand Down
3 changes: 2 additions & 1 deletion apps/frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { draftMode } from "next/headers";
import dynamic from "next/dynamic";
import { draftMode } from "next/headers";

import { loadHomePage } from "../sanity";
import { HomeLayout } from "./HomeLayout";

Expand Down
Loading