Skip to content

Commit

Permalink
🚀 feat(api): add no-cache option to tRPC routers (saasfly#81)
Browse files Browse the repository at this point in the history
* 🚀 feat(api): add no-cache option to tRPC routers
  • Loading branch information
nextify authored Jul 13, 2024
1 parent 572be98 commit 1232f2a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
20 changes: 10 additions & 10 deletions apps/nextjs/src/app/[lang]/(marketing)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ export default async function IndexPage({

return (
<>
<section className="xl:h-[100vh] w-full px-8 sm:px-48 xl:px-48 md:px-48">
<div className="grid grid-cols-1 xl:grid-cols-2 gap-10 pb-10 md:pb-40">
<section className="w-full px-8 sm:px-48 md:px-48 xl:h-[100vh] xl:px-48">
<div className="grid grid-cols-1 gap-10 pb-10 md:pb-40 xl:grid-cols-2">
<div className="flex flex-col items-start">
<div className="flex flex-col pt-4 lg:pt-28 xl:pt-28 md:pt-28">
<div className="flex flex-col pt-4 md:pt-28 lg:pt-28 xl:pt-28">
<Link href="https://document.saasfly.io" target="_blank">
<DocumentGuide>
{dict.marketing.introducing || "Introducing Saasfly"}
Expand All @@ -60,9 +60,9 @@ export default async function IndexPage({
<TypewriterEffectSmooths />
</div>

<div className="mt-6 flex sm:flex-row flex-col space-y-4 justify-center sm:space-y-0 sm:space-x-8 sm:justify-start mb-4 w-full">
<div className="mb-4 mt-6 flex w-full flex-col justify-center space-y-4 sm:flex-row sm:justify-start sm:space-x-8 sm:space-y-0">
<Link href={`${lang}/login`}>
<ShimmerButton className="flex justify-center mx-auto">
<ShimmerButton className="mx-auto flex justify-center">
<span className="z-10 w-48 whitespace-pre bg-gradient-to-b from-black from-30% to-gray-300/80 bg-clip-text text-center text-sm font-semibold leading-none tracking-tight text-white dark:from-white dark:to-slate-900/10 dark:text-transparent">
{dict.marketing.get_started}
</span>
Expand All @@ -81,7 +81,7 @@ export default async function IndexPage({
</div>
</div>

<div className="h-full w-full hidden xl:block">
<div className="hidden h-full w-full xl:block">
<div className="flex flex-col pt-28">
<Meteorss meteor={meteors_data} />
<div className="mt-4 flex w-full justify-between">
Expand All @@ -95,7 +95,7 @@ export default async function IndexPage({
</div>
</section>

<section className="h-[100vh] w-full hidden xl:block">
<section className="hidden h-[100vh] w-full xl:block">
<div className="flex h-full w-full justify-between px-[220px]">
<div className="flex w-[60%] flex-col pr-4 pt-40">
<WobbleCardShow />
Expand All @@ -108,7 +108,7 @@ export default async function IndexPage({
</div>
</section>

<section className="h-[100vh] w-full hidden xl:block">
<section className="hidden h-[100vh] w-full xl:block">
<div className="flex h-full w-full justify-between px-[220px]">
<div className="flex w-[60%] flex-col pr-4 pt-40">
<div className="px-[120px]">
Expand All @@ -118,11 +118,11 @@ export default async function IndexPage({
</div>
</section>

<section className="w-full xl:hidden px-8">
<section className="w-full px-8 xl:hidden">
<Questions />
</section>

<section className="w-full px-8 pt-10 sm:px-0 xl:px-0 md:px-0 sm:pt-0 xl:pt-0 md:pt-0">
<section className="w-full px-8 pt-10 sm:px-0 sm:pt-0 md:px-0 md:pt-0 xl:px-0 xl:pt-0">
<div className="flex h-full w-full flex-col items-center pb-[100px] pt-10">
<div>
<h1 className="mb-6 text-center text-3xl font-bold dark:text-zinc-100 md:text-5xl">
Expand Down
3 changes: 3 additions & 0 deletions packages/api/src/router/auth.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { unstable_noStore as noStore } from "next/cache";

import { db } from "@saasfly/db";

import { createTRPCRouter, protectedProcedure } from "../trpc";

export const authRouter = createTRPCRouter({
mySubscription: protectedProcedure.query(async (opts) => {
noStore();
const userId = opts.ctx.userId as string;
const customer = await db
.selectFrom("Customer")
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/router/customer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { unstable_noStore as noStore } from "next/cache";
import { getServerSession } from "next-auth/next";
import { z } from "zod";

Expand Down Expand Up @@ -51,6 +52,7 @@ export const customerRouter = createTRPCRouter({
queryCustomer: protectedProcedure
.input(insertCustomerSchema)
.query(async ({ input }) => {
noStore();
const { userId } = input;
console.log("userId:", userId);
try {
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/router/k8s.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { unstable_noStore as noStore } from "next/cache";
import { TRPCError } from "@trpc/server";
import { getServerSession } from "next-auth/next";
import { z } from "zod";
Expand All @@ -19,6 +20,7 @@ const k8sClusterDeleteSchema = z.object({

export const k8sRouter = createTRPCRouter({
getClusters: protectedProcedure.query(async (opts) => {
noStore();
const session = await getServerSession(authOptions);
const userId = opts.ctx.userId! as string;
if (!session) {
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/router/stripe.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { unstable_noStore as noStore } from "next/cache";
import { z } from "zod";

import { getCurrentUser } from "@saasfly/auth";
Expand Down Expand Up @@ -112,6 +113,7 @@ export const stripeRouter = createTRPCRouter({
userPlans: protectedProcedure
// .output(Promise<UserSubscriptionPlan>)
.query(async (opts) => {
noStore();
const userId = opts.ctx.userId! as string;
const custom = await db
.selectFrom("Customer")
Expand Down

0 comments on commit 1232f2a

Please sign in to comment.