Skip to content

Commit

Permalink
update path alias & remove edge runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
noxify committed Jan 8, 2024
1 parent c4fbc38 commit 1789a7e
Show file tree
Hide file tree
Showing 9 changed files with 426 additions and 169 deletions.
2 changes: 1 addition & 1 deletion apps/nextjs/next.config.js → apps/nextjs/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Importing env files here to validate on build
import "./src/env.js";
import "./src/env.mjs";
import "@acme/auth/env";

/** @type {import("next").NextConfig} */
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/app/_components/posts.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use client";

import { api } from "@/trpc/react";

import type { RouterOutputs } from "@acme/api";
import { cn } from "@acme/ui";
import { Button } from "@acme/ui/button";
Expand All @@ -15,8 +17,6 @@ import { Input } from "@acme/ui/input";
import { toast } from "@acme/ui/toast";
import { CreatePostSchema } from "@acme/validators";

import { api } from "~/trpc/react";

export function CreatePostForm() {
const form = useForm({
schema: CreatePostSchema,
Expand Down
2 changes: 0 additions & 2 deletions apps/nextjs/src/app/api/trpc/[trpc]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
import { appRouter, createTRPCContext } from "@acme/api";
import { auth } from "@acme/auth";

export const runtime = "edge";

/**
* Configure basic CORS headers
* You should extend this to match your needs
Expand Down
36 changes: 6 additions & 30 deletions apps/nextjs/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,20 @@
import type { Metadata, Viewport } from "next";
import type { Metadata } from "next";
import { cache } from "react";
import { headers } from "next/headers";
import { TRPCReactProvider } from "@/trpc/react";
import { GeistMono } from "geist/font/mono";
import { GeistSans } from "geist/font/sans";

import { cn } from "@acme/ui";
import { ThemeProvider, ThemeToggle } from "@acme/ui/theme";
import { Toaster } from "@acme/ui/toast";

import { env } from "~/env";
import { TRPCReactProvider } from "~/trpc/react";

import "~/app/globals.css";
import "@/app/globals.css";

export const metadata: Metadata = {
metadataBase: new URL(
env.VERCEL_ENV === "production"
? "https://turbo.t3.gg"
: "http://localhost:3000",
),
title: "Create T3 Turbo",
description: "Simple monorepo with shared backend for web & mobile apps",
openGraph: {
title: "Create T3 Turbo",
description: "Simple monorepo with shared backend for web & mobile apps",
url: "https://create-t3-turbo.vercel.app",
siteName: "Create T3 Turbo",
},
twitter: {
card: "summary_large_image",
site: "@jullerino",
creator: "@jullerino",
},
};

export const viewport: Viewport = {
themeColor: [
{ media: "(prefers-color-scheme: light)", color: "white" },
{ media: "(prefers-color-scheme: dark)", color: "black" },
],
metadataBase: new URL("http://localhost:3000"),
title: "T3 Turbo - Lucia",
description: "Simple monorepo with shared backend for web apps",
};

const getHeaders = cache(async () => headers());
Expand Down
4 changes: 1 addition & 3 deletions apps/nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { Suspense } from "react";
import { api } from "@/trpc/server";

import { api } from "~/trpc/server";
import { AuthShowcase } from "./_components/auth-showcase";
import {
CreatePostForm,
PostCardSkeleton,
PostList,
} from "./_components/posts";

export const runtime = "edge";

export default async function HomePage() {
// You don't need to fetch these here, just showing different usages
// If you don't want the Suspense loading state, you could pass these
Expand Down
8 changes: 0 additions & 8 deletions apps/nextjs/src/env.js → apps/nextjs/src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ export const env = createEnv({
NODE_ENV: z
.enum(["development", "production", "test"])
.default("development"),
VERCEL_ENV: z.enum(["development", "preview", "production"]).optional(),
VERCEL_URL: z
.string()
.optional()
.transform((v) => (v ? `https://${v}` : undefined)),
PORT: z.coerce.number().default(3000),
},
/**
Expand Down Expand Up @@ -39,9 +34,6 @@ export const env = createEnv({
DB_PASSWORD: process.env.DB_PASSWORD,
DB_USERNAME: process.env.DB_USERNAME,
PORT: process.env.PORT,
VERCEL_URL: process.env.VERCEL_URL,

// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
},
skipValidation:
!!process.env.CI ||
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"baseUrl": ".",
"paths": {
"~/*": ["./src/*"]
"@/*": ["./src/*"]
},
"plugins": [{ "name": "next" }],
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
Expand Down
Loading

0 comments on commit 1789a7e

Please sign in to comment.