diff --git a/src/pages/sign-up/[[...index]].tsx b/src/app/sign-up/[[...sign-up]]/page.tsx
similarity index 85%
rename from src/pages/sign-up/[[...index]].tsx
rename to src/app/sign-up/[[...sign-up]]/page.tsx
index ce6c5ea..26adc28 100644
--- a/src/pages/sign-up/[[...index]].tsx
+++ b/src/app/sign-up/[[...sign-up]]/page.tsx
@@ -1,5 +1,9 @@
+"use client";
+
import { SignUp } from "@clerk/nextjs";
+export const dynamic = "force-static";
+
const SignUpPage = () => (
diff --git a/src/components/templates/Welcome.tsx b/src/components/templates/Welcome.tsx
deleted file mode 100644
index 6d4cf2f..0000000
--- a/src/components/templates/Welcome.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-import {
- Body,
- Container,
- Head,
- Heading,
- Hr,
- Html,
- Img,
- Preview,
- Section,
- Text,
-} from "@react-email/components";
-import * as React from "react";
-
-interface WelcomeTemplateProps {
- name: string;
-}
-
-const baseUrl = process.env.VERCEL_URL
- ? `https://${process.env.VERCEL_URL}`
- : "http://localhost:3000";
-
-export const Welcome = ({ name }: WelcomeTemplateProps) => (
-
-
-
🎉 Welcome to Sprint Padawan! 🎉
-
-
-
-
-
-
- 🎉 Welcome to Sprint Padawan, {name}! 🎉
-
- Hello {name},
- Thank you for signing up for Sprint Padawan!
-
- If at any point you encounter issues, please let me know at
- support@sprintpadawan.dev.
-
-
- — Atridad Lahiji
-
-
-
-);
diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx
deleted file mode 100644
index d8c87a0..0000000
--- a/src/pages/_app.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { type AppType } from "next/app";
-import { ClerkProvider } from "@clerk/nextjs";
-
-import { api } from "~/utils/api";
-
-import Footer from "~/components/Footer";
-import Navbar from "~/components/Navbar";
-import "~/styles/globals.css";
-
-const MyApp: AppType = ({ Component, pageProps }) => {
- return (
-
-
-
- );
-};
-
-export default api.withTRPC(MyApp);
diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx
deleted file mode 100644
index 1073f40..0000000
--- a/src/pages/_document.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { Head, Html, Main, NextScript } from "next/document";
-
-export default function Document() {
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
-}
diff --git a/src/pages/api/[...trpc].ts b/src/pages/api/[...trpc].ts
deleted file mode 100644
index 331d609..0000000
--- a/src/pages/api/[...trpc].ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { appRouter } from "~/server/api/root";
-import { createTRPCContext } from "~/server/api/trpc";
-import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
-import type { NextRequest } from "next/server";
-
-export const config = {
- runtime: "edge",
- regions: ["pdx1"],
- unstable_allowDynamic: ["/node_modules/ably/**"],
-};
-
-export default async function handler(req: NextRequest) {
- return fetchRequestHandler({
- endpoint: "/api/trpc",
- router: appRouter,
- req,
- createContext: createTRPCContext,
- });
-}
diff --git a/src/pages/api/trpc/[...trpc].ts b/src/pages/api/trpc/[...trpc].ts
deleted file mode 100644
index 331d609..0000000
--- a/src/pages/api/trpc/[...trpc].ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { appRouter } from "~/server/api/root";
-import { createTRPCContext } from "~/server/api/trpc";
-import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
-import type { NextRequest } from "next/server";
-
-export const config = {
- runtime: "edge",
- regions: ["pdx1"],
- unstable_allowDynamic: ["/node_modules/ably/**"],
-};
-
-export default async function handler(req: NextRequest) {
- return fetchRequestHandler({
- endpoint: "/api/trpc",
- router: appRouter,
- req,
- createContext: createTRPCContext,
- });
-}
diff --git a/src/server/api/root.ts b/src/server/api/root.ts
deleted file mode 100644
index 46b8d53..0000000
--- a/src/server/api/root.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { roomRouter } from "~/server/api/routers/room";
-import { createTRPCRouter } from "~/server/api/trpc";
-import { voteRouter } from "./routers/vote";
-
-/**
- * This is the primary router for your server.
- *
- * All routers added in /api/routers should be manually added here.
- */
-export const appRouter = createTRPCRouter({
- room: roomRouter,
- vote: voteRouter,
-});
-
-// export type definition of API
-export type AppRouter = typeof appRouter;
diff --git a/src/server/api/trpc.ts b/src/server/api/trpc.ts
deleted file mode 100644
index 4fb0bfd..0000000
--- a/src/server/api/trpc.ts
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * YOU PROBABLY DON'T NEED TO EDIT THIS FILE, UNLESS:
- * 1. You want to modify request context (see Part 1)
- * 2. You want to create a new middleware or type of procedure (see Part 3)
- *
- * tl;dr - this is where all the tRPC server stuff is created and plugged in.
- * The pieces you will need to use are documented accordingly near the end
- */
-
-/**
- * 1. CONTEXT
- *
- * This section defines the "contexts" that are available in the backend API
- *
- * These allow you to access things like the database, the session, etc, when
- * processing a request
- *
- */
-import { type FetchCreateContextFnOptions } from "@trpc/server/adapters/fetch";
-import { getAuth } from "@clerk/nextjs/server";
-import type {
- SignedInAuthObject,
- SignedOutAuthObject,
-} from "@clerk/nextjs/api";
-
-import { db } from "../db";
-
-interface AuthContext {
- auth: SignedInAuthObject | SignedOutAuthObject;
-}
-/**
- * This helper generates the "internals" for a tRPC context. If you need to use
- * it, you can export it from here
- *
- * Examples of things you may need it for:
- * - testing, so we dont have to mock Next.js' req/res
- * - trpc's `createSSGHelpers` where we don't have req/res
- * @see https://create.t3.gg/en/usage/trpc#-servertrpccontextts
- */
-
-const createInnerTRPCContext = ({ auth }: AuthContext) => {
- return {
- auth,
- db,
- };
-};
-
-export const createTRPCContext = ({ req }: FetchCreateContextFnOptions) => {
- return createInnerTRPCContext({ auth: getAuth(req as NextRequest) });
-};
-
-export type Context = inferAsyncReturnType
;
-
-/**
- * 2. INITIALIZATION
- *
- * This is where the trpc api is initialized, connecting the context and
- * transformer
- */
-import { type inferAsyncReturnType, initTRPC, TRPCError } from "@trpc/server";
-import superjson from "superjson";
-import type { NextRequest } from "next/server";
-
-const t = initTRPC.context().create({
- transformer: superjson,
- errorFormatter({ shape }) {
- return shape;
- },
-});
-
-// check if the user is signed in, otherwise through a UNAUTHORIZED CODE
-const isAuthed = t.middleware(({ next, ctx }) => {
- if (!ctx.auth.userId) {
- throw new TRPCError({ code: "UNAUTHORIZED" });
- }
-
- return next({
- ctx: {
- auth: ctx.auth,
- },
- });
-});
-/**
- * 3. ROUTER & PROCEDURE (THE IMPORTANT BIT)
- *
- * These are the pieces you use to build your tRPC API. You should import these
- * a lot in the /src/server/api/routers folder
- */
-
-/**
- * This is how you create new routers and subrouters in your tRPC API
- * @see https://trpc.io/docs/router
- */
-export const createTRPCRouter = t.router;
-
-/**
- * Public (unauthed) procedure
- *
- * This is the base piece you use to build new queries and mutations on your
- * tRPC API. It does not guarantee that a user querying is authorized, but you
- * can still access user session data if they are logged in
- */
-export const publicProcedure = t.procedure;
-export const protectedProcedure = t.procedure.use(isAuthed);
diff --git a/src/server/trpc/index.ts b/src/server/trpc/index.ts
new file mode 100644
index 0000000..8b6cef1
--- /dev/null
+++ b/src/server/trpc/index.ts
@@ -0,0 +1,10 @@
+import { createTRPCRouter } from "./trpc";
+import { roomRouter } from "./routers/room";
+import { voteRouter } from "./routers/vote";
+
+export const appRouter = createTRPCRouter({
+ room: roomRouter,
+ vote: voteRouter,
+});
+
+export type AppRouter = typeof appRouter;
diff --git a/src/server/api/routers/room.ts b/src/server/trpc/routers/room.ts
similarity index 98%
rename from src/server/api/routers/room.ts
rename to src/server/trpc/routers/room.ts
index f433a3a..a952e02 100644
--- a/src/server/api/routers/room.ts
+++ b/src/server/trpc/routers/room.ts
@@ -1,6 +1,6 @@
import { z } from "zod";
import { publishToChannel } from "~/server/ably";
-import { createTRPCRouter, protectedProcedure } from "~/server/api/trpc";
+import { createTRPCRouter, protectedProcedure } from "~/server/trpc/trpc";
import { fetchCache, invalidateCache, setCache } from "~/server/redis";
import { logs, rooms, votes } from "~/server/schema";
diff --git a/src/server/api/routers/vote.ts b/src/server/trpc/routers/vote.ts
similarity index 96%
rename from src/server/api/routers/vote.ts
rename to src/server/trpc/routers/vote.ts
index 05326a7..f4a4f0b 100644
--- a/src/server/api/routers/vote.ts
+++ b/src/server/trpc/routers/vote.ts
@@ -1,7 +1,7 @@
import { z } from "zod";
import { publishToChannel } from "~/server/ably";
-import { createTRPCRouter, protectedProcedure } from "~/server/api/trpc";
+import { createTRPCRouter, protectedProcedure } from "~/server/trpc/trpc";
import { fetchCache, invalidateCache, setCache } from "~/server/redis";
import { EventTypes } from "~/utils/types";
import { eq } from "drizzle-orm";
diff --git a/src/server/trpc/trpc.ts b/src/server/trpc/trpc.ts
new file mode 100644
index 0000000..a64a62e
--- /dev/null
+++ b/src/server/trpc/trpc.ts
@@ -0,0 +1,50 @@
+import type {
+ SignedInAuthObject,
+ SignedOutAuthObject,
+} from "@clerk/nextjs/api";
+import { getAuth } from "@clerk/nextjs/server";
+import { TRPCError, type inferAsyncReturnType, initTRPC } from "@trpc/server";
+import { db } from "../db";
+import { FetchCreateContextFnOptions } from "@trpc/server/adapters/fetch";
+import { NextRequest } from "next/server";
+import superjson from "superjson";
+
+interface AuthContext {
+ auth: SignedInAuthObject | SignedOutAuthObject;
+}
+
+const createInnerTRPCContext = ({ auth }: AuthContext) => {
+ return {
+ auth,
+ db,
+ };
+};
+
+export const createTRPCContext = ({ req }: FetchCreateContextFnOptions) => {
+ return createInnerTRPCContext({ auth: getAuth(req as NextRequest) });
+};
+
+export type Context = inferAsyncReturnType;
+
+const t = initTRPC.context().create({
+ transformer: superjson,
+ errorFormatter({ shape }) {
+ return shape;
+ },
+});
+// check if the user is signed in, otherwise through a UNAUTHORIZED CODE
+const isAuthed = t.middleware(({ next, ctx }) => {
+ if (!ctx.auth.userId) {
+ throw new TRPCError({ code: "UNAUTHORIZED" });
+ }
+
+ return next({
+ ctx: {
+ auth: ctx.auth,
+ },
+ });
+});
+
+export const createTRPCRouter = t.router;
+export const publicProcedure = t.procedure;
+export const protectedProcedure = t.procedure.use(isAuthed);
diff --git a/src/server/webhookHelpers.ts b/src/server/webhookHelpers.ts
index f76c382..2e6c7f5 100644
--- a/src/server/webhookHelpers.ts
+++ b/src/server/webhookHelpers.ts
@@ -2,10 +2,6 @@ import { eq } from "drizzle-orm";
import { db } from "./db";
import { rooms } from "./schema";
import { env } from "~/env.mjs";
-import { Welcome } from "~/components/templates/Welcome";
-import { Resend } from "resend";
-
-const resend = new Resend(env.RESEND_API_KEY);
export const onUserDeletedHandler = async (userId: string) => {
try {
@@ -17,11 +13,7 @@ export const onUserDeletedHandler = async (userId: string) => {
}
};
-export const onUserCreatedHandler = async (
- userId: string,
- userEmails: string[],
- userName?: string
-) => {
+export const onUserCreatedHandler = async (userId: string) => {
const userUpdateResponse = await fetch(
`https://api.clerk.com/v1/users/${userId}/metadata`,
{
@@ -41,16 +33,5 @@ export const onUserCreatedHandler = async (
}
);
- if (userUpdateResponse.ok) {
- userEmails.forEach((userEmail) => {
- void resend.sendEmail({
- from: "no-reply@sprintpadawan.dev",
- to: userEmail,
- subject: "🎉 Welcome to Sprint Padawan! 🎉",
- react: Welcome({ name: userName ? userEmail : userEmail }),
- });
- });
- }
-
return userUpdateResponse.ok;
};
diff --git a/src/styles/globals.css b/src/styles/globals.css
index 63cf0a5..b5c61c9 100644
--- a/src/styles/globals.css
+++ b/src/styles/globals.css
@@ -1,12 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
-
-html,
-container,
-body #__next {
- height: 100%;
- width: 100%;
- overflow-y: auto;
- position: fixed;
-}
\ No newline at end of file
diff --git a/src/utils/api.ts b/src/utils/api.ts
deleted file mode 100644
index f4f4ad5..0000000
--- a/src/utils/api.ts
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * This is the client-side entrypoint for your tRPC API. It is used to create the `api` object which
- * contains the Next.js App-wrapper, as well as your type-safe React Query hooks.
- *
- * We also create a few inference helpers for input and output types.
- */
-import { httpBatchLink, loggerLink } from "@trpc/client";
-import { createTRPCNext } from "@trpc/next";
-import { type inferRouterInputs, type inferRouterOutputs } from "@trpc/server";
-import superjson from "superjson";
-
-import { type AppRouter } from "~/server/api/root";
-
-const getBaseUrl = () => {
- if (typeof window !== "undefined") return ""; // browser should use relative url
- if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}`; // SSR should use vercel url
- return `http://localhost:${process.env.PORT ?? 3000}`; // dev SSR should use localhost
-};
-
-/** A set of type-safe react-query hooks for your tRPC API. */
-export const api = createTRPCNext({
- config() {
- return {
- /**
- * Transformer used for data de-serialization from the server.
- *
- * @see https://trpc.io/docs/data-transformers
- */
- transformer: superjson,
-
- /**
- * Links used to determine request flow from client to server.
- *
- * @see https://trpc.io/docs/links
- */
- links: [
- loggerLink({
- enabled: (opts) =>
- process.env.NODE_ENV === "development" ||
- (opts.direction === "down" && opts.result instanceof Error),
- }),
- httpBatchLink({
- url: `${getBaseUrl()}/api/trpc`,
- }),
- ],
- };
- },
- /**
- * Whether tRPC should await queries when server rendering pages.
- *
- * @see https://trpc.io/docs/nextjs#ssr-boolean-default-false
- */
- ssr: false,
-});
-
-/**
- * Inference helper for inputs.
- *
- * @example type HelloInput = RouterInputs['example']['hello']
- */
-export type RouterInputs = inferRouterInputs;
-
-/**
- * Inference helper for outputs.
- *
- * @example type HelloOutput = RouterOutputs['example']['hello']
- */
-export type RouterOutputs = inferRouterOutputs;
diff --git a/tsconfig.json b/tsconfig.json
index 03ebb74..bf347be 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,7 +1,11 @@
{
"compilerOptions": {
"target": "es2017",
- "lib": ["dom", "dom.iterable", "esnext"],
+ "lib": [
+ "dom",
+ "dom.iterable",
+ "esnext"
+ ],
"allowJs": true,
"checkJs": true,
"skipLibCheck": true,
@@ -18,8 +22,15 @@
"noUncheckedIndexedAccess": true,
"baseUrl": ".",
"paths": {
- "~/*": ["./src/*"]
- }
+ "~/*": [
+ "./src/*"
+ ]
+ },
+ "plugins": [
+ {
+ "name": "next"
+ }
+ ]
},
"include": [
".eslintrc.cjs",
@@ -27,7 +38,10 @@
"**/*.ts",
"**/*.tsx",
"**/*.cjs",
- "**/*.mjs"
+ "**/*.mjs",
+ ".next/types/**/*.ts"
],
- "exclude": ["node_modules"]
+ "exclude": [
+ "node_modules"
+ ]
}