-
-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Migrating to trpc instead of next's route handers
- Loading branch information
1 parent
c2f1d6d
commit 2c2d05f
Showing
26 changed files
with
299 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { PrismaClient } from "@prisma/client"; | ||
|
||
const prisma = new PrismaClient({ | ||
log: | ||
process.env.NODE_ENV === "development" | ||
? ["query", "error", "warn"] | ||
: ["error"], | ||
}); | ||
|
||
// For some weird reason accessing @prisma/client from any package is causing problems (specially in error handling). | ||
// Re export them here instead. | ||
export * from "@prisma/client"; | ||
const globalForPrisma = globalThis as unknown as { | ||
prisma: PrismaClient | undefined; | ||
}; | ||
|
||
export default prisma; | ||
export const prisma = | ||
globalForPrisma.prisma ?? | ||
new PrismaClient({ | ||
log: | ||
process.env.NODE_ENV === "development" | ||
? ["query", "error", "warn"] | ||
: ["error"], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { authHandler } from "@/lib/auth"; | ||
import { authHandler } from "@/server/auth"; | ||
|
||
export { authHandler as GET, authHandler as POST }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import { fetchRequestHandler } from '@trpc/server/adapters/fetch'; | ||
import { appRouter } from '@/server/routers/_app'; | ||
import { fetchRequestHandler } from "@trpc/server/adapters/fetch"; | ||
import { appRouter } from "@/server/api/routers/_app"; | ||
import { createContext } from "@/server/api/client"; | ||
|
||
const handler = (req: Request) => | ||
fetchRequestHandler({ | ||
endpoint: '/api/trpc', | ||
endpoint: "/api/trpc", | ||
req, | ||
router: appRouter, | ||
createContext: () => ({}) | ||
createContext, | ||
}); | ||
export { handler as GET, handler as POST }; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import Bookmarks from "../components/Bookmarks"; | ||
|
||
export default async function ArchivedBookmarkPage() { | ||
return <Bookmarks title="Archive" archived={true} favourited={false} />; | ||
return <Bookmarks title="Archive" archived={true} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.