0pflow 0.1.0-dev.06e289c → 0.1.0-dev.3f15251
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +3 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/install.d.ts.map +1 -1
- package/dist/cli/install.js +11 -25
- package/dist/cli/install.js.map +1 -1
- package/dist/cli/mcp/config.d.ts +1 -0
- package/dist/cli/mcp/config.d.ts.map +1 -1
- package/dist/cli/mcp/config.js +4 -2
- package/dist/cli/mcp/config.js.map +1 -1
- package/dist/cli/mcp/tools/createApp.d.ts.map +1 -1
- package/dist/cli/mcp/tools/createApp.js +6 -6
- package/dist/cli/mcp/tools/createApp.js.map +1 -1
- package/dist/cli/mcp/tools/setupAppSchema.d.ts.map +1 -1
- package/dist/cli/mcp/tools/setupAppSchema.js +2 -5
- package/dist/cli/mcp/tools/setupAppSchema.js.map +1 -1
- package/package.json +2 -3
- package/templates/app/.env.example +0 -13
- package/templates/app/README.md +0 -29
- package/templates/app/biome.jsonc +0 -81
- package/templates/app/drizzle.config.ts +0 -12
- package/templates/app/next.config.js +0 -10
- package/templates/app/package.json +0 -52
- package/templates/app/postcss.config.js +0 -5
- package/templates/app/public/favicon.ico +0 -0
- package/templates/app/src/app/_components/.gitkeep +0 -0
- package/templates/app/src/app/api/trpc/[trpc]/route.ts +0 -34
- package/templates/app/src/app/layout.tsx +0 -29
- package/templates/app/src/app/page.tsx +0 -18
- package/templates/app/src/env.js +0 -46
- package/templates/app/src/server/api/root.ts +0 -21
- package/templates/app/src/server/api/routers/.gitkeep +0 -0
- package/templates/app/src/server/api/trpc.ts +0 -106
- package/templates/app/src/server/db/index.ts +0 -18
- package/templates/app/src/server/db/schema.ts +0 -14
- package/templates/app/src/styles/globals.css +0 -6
- package/templates/app/src/styles/globals.css.orange +0 -126
- package/templates/app/src/trpc/query-client.ts +0 -25
- package/templates/app/src/trpc/react.tsx +0 -78
- package/templates/app/src/trpc/server.ts +0 -30
- package/templates/app/tsconfig.check.json +0 -23
- package/templates/app/tsconfig.json +0 -42
- package/templates/app/tsconfig.server.json +0 -5
- package/templates/app/tsconfig.test.json +0 -21
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
|
|
2
|
-
import { type NextRequest } from "next/server";
|
|
3
|
-
|
|
4
|
-
import { env } from "~/env";
|
|
5
|
-
import { appRouter } from "~/server/api/root";
|
|
6
|
-
import { createTRPCContext } from "~/server/api/trpc";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when
|
|
10
|
-
* handling a HTTP request (e.g. when you make requests from Client Components).
|
|
11
|
-
*/
|
|
12
|
-
const createContext = async (req: NextRequest) => {
|
|
13
|
-
return createTRPCContext({
|
|
14
|
-
headers: req.headers,
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const handler = (req: NextRequest) =>
|
|
19
|
-
fetchRequestHandler({
|
|
20
|
-
endpoint: "/api/trpc",
|
|
21
|
-
req,
|
|
22
|
-
router: appRouter,
|
|
23
|
-
createContext: () => createContext(req),
|
|
24
|
-
onError:
|
|
25
|
-
env.NODE_ENV === "development"
|
|
26
|
-
? ({ path, error }) => {
|
|
27
|
-
console.error(
|
|
28
|
-
`❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message}`
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
: undefined,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
export { handler as GET, handler as POST };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import "~/styles/globals.css";
|
|
2
|
-
|
|
3
|
-
import { type Metadata } from "next";
|
|
4
|
-
import { Geist } from "next/font/google";
|
|
5
|
-
|
|
6
|
-
import { TRPCReactProvider } from "~/trpc/react";
|
|
7
|
-
|
|
8
|
-
export const metadata: Metadata = {
|
|
9
|
-
title: "{{app_name}}",
|
|
10
|
-
description: "{{product_brief}}",
|
|
11
|
-
icons: [{ rel: "icon", url: "/favicon.ico" }],
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const geist = Geist({
|
|
15
|
-
subsets: ["latin"],
|
|
16
|
-
variable: "--font-geist-sans",
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export default function RootLayout({
|
|
20
|
-
children,
|
|
21
|
-
}: Readonly<{ children: React.ReactNode }>) {
|
|
22
|
-
return (
|
|
23
|
-
<html lang="en" className={`${geist.variable}`}>
|
|
24
|
-
<body>
|
|
25
|
-
<TRPCReactProvider>{children}</TRPCReactProvider>
|
|
26
|
-
</body>
|
|
27
|
-
</html>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { HydrateClient } from "~/trpc/server";
|
|
2
|
-
|
|
3
|
-
export default async function Home() {
|
|
4
|
-
return (
|
|
5
|
-
<HydrateClient>
|
|
6
|
-
<main className="flex min-h-screen flex-col items-center justify-center bg-gradient-to-b from-[#2e026d] to-[#15162c] text-white">
|
|
7
|
-
<div className="container flex flex-col items-center justify-center gap-12 px-4 py-16">
|
|
8
|
-
<h1 className="text-5xl font-extrabold tracking-tight sm:text-[5rem]">
|
|
9
|
-
{{app_name}}
|
|
10
|
-
</h1>
|
|
11
|
-
<p className="text-2xl text-white/70">
|
|
12
|
-
0pflow workflow app
|
|
13
|
-
</p>
|
|
14
|
-
</div>
|
|
15
|
-
</main>
|
|
16
|
-
</HydrateClient>
|
|
17
|
-
);
|
|
18
|
-
}
|
package/templates/app/src/env.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { createEnv } from "@t3-oss/env-nextjs";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
export const env = createEnv({
|
|
5
|
-
/**
|
|
6
|
-
* Specify your server-side environment variables schema here. This way you can ensure the app
|
|
7
|
-
* isn't built with invalid env vars.
|
|
8
|
-
*/
|
|
9
|
-
server: {
|
|
10
|
-
DATABASE_URL: z.string().url(),
|
|
11
|
-
DATABASE_SCHEMA: z.string().default("{{app_name}}"),
|
|
12
|
-
NODE_ENV: z
|
|
13
|
-
.enum(["development", "test", "production"])
|
|
14
|
-
.default("development"),
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Specify your client-side environment variables schema here. This way you can ensure the app
|
|
19
|
-
* isn't built with invalid env vars. To expose them to the client, prefix them with
|
|
20
|
-
* `NEXT_PUBLIC_`.
|
|
21
|
-
*/
|
|
22
|
-
client: {
|
|
23
|
-
// NEXT_PUBLIC_CLIENTVAR: z.string(),
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
|
|
28
|
-
* middlewares) or client-side so we need to destruct manually.
|
|
29
|
-
*/
|
|
30
|
-
runtimeEnv: {
|
|
31
|
-
DATABASE_URL: process.env.DATABASE_URL,
|
|
32
|
-
DATABASE_SCHEMA: process.env.DATABASE_SCHEMA,
|
|
33
|
-
NODE_ENV: process.env.NODE_ENV,
|
|
34
|
-
// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
|
|
35
|
-
},
|
|
36
|
-
/**
|
|
37
|
-
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
|
|
38
|
-
* useful for Docker builds.
|
|
39
|
-
*/
|
|
40
|
-
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
|
|
41
|
-
/**
|
|
42
|
-
* Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and
|
|
43
|
-
* `SOME_VAR=''` will throw an error.
|
|
44
|
-
*/
|
|
45
|
-
emptyStringAsUndefined: true,
|
|
46
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createCallerFactory, createTRPCRouter, publicProcedure } from "~/server/api/trpc";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This is the primary router for your server.
|
|
5
|
-
*
|
|
6
|
-
* All routers added in /api/routers should be manually added here.
|
|
7
|
-
*/
|
|
8
|
-
export const appRouter = createTRPCRouter({
|
|
9
|
-
health: publicProcedure.query(() => ({ status: "ok" })),
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
// export type definition of API
|
|
13
|
-
export type AppRouter = typeof appRouter;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Create a server-side caller for the tRPC API.
|
|
17
|
-
* @example
|
|
18
|
-
* const trpc = createCaller(createContext);
|
|
19
|
-
* const res = await trpc.health();
|
|
20
|
-
*/
|
|
21
|
-
export const createCaller = createCallerFactory(appRouter);
|
|
File without changes
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* YOU PROBABLY DON'T NEED TO EDIT THIS FILE, UNLESS:
|
|
3
|
-
* 1. You want to modify request context (see Part 1).
|
|
4
|
-
* 2. You want to create a new middleware or type of procedure (see Part 3).
|
|
5
|
-
*
|
|
6
|
-
* TL;DR - This is where all the tRPC server stuff is created and plugged in. The pieces you will
|
|
7
|
-
* need to use are documented accordingly near the end.
|
|
8
|
-
*/
|
|
9
|
-
import { initTRPC } from "@trpc/server";
|
|
10
|
-
import superjson from "superjson";
|
|
11
|
-
import { ZodError } from "zod";
|
|
12
|
-
|
|
13
|
-
import { db } from "~/server/db";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 1. CONTEXT
|
|
17
|
-
*
|
|
18
|
-
* This section defines the "contexts" that are available in the backend API.
|
|
19
|
-
*
|
|
20
|
-
* These allow you to access things when processing a request, like the database, the session, etc.
|
|
21
|
-
*
|
|
22
|
-
* This helper generates the "internals" for a tRPC context. The API handler and RSC clients each
|
|
23
|
-
* wrap this and provides the required context.
|
|
24
|
-
*
|
|
25
|
-
* @see https://trpc.io/docs/server/context
|
|
26
|
-
*/
|
|
27
|
-
export const createTRPCContext = async (opts: { headers: Headers }) => {
|
|
28
|
-
return {
|
|
29
|
-
db,
|
|
30
|
-
...opts,
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* 2. INITIALIZATION
|
|
36
|
-
*
|
|
37
|
-
* This is where the tRPC API is initialized, connecting the context and transformer. We also parse
|
|
38
|
-
* ZodErrors so that you get typesafety on the frontend if your procedure fails due to validation
|
|
39
|
-
* errors on the backend.
|
|
40
|
-
*/
|
|
41
|
-
const t = initTRPC.context<typeof createTRPCContext>().create({
|
|
42
|
-
transformer: superjson,
|
|
43
|
-
errorFormatter({ shape, error }) {
|
|
44
|
-
return {
|
|
45
|
-
...shape,
|
|
46
|
-
data: {
|
|
47
|
-
...shape.data,
|
|
48
|
-
zodError:
|
|
49
|
-
error.cause instanceof ZodError ? error.cause.flatten() : null,
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Create a server-side caller.
|
|
57
|
-
*
|
|
58
|
-
* @see https://trpc.io/docs/server/server-side-calls
|
|
59
|
-
*/
|
|
60
|
-
export const createCallerFactory = t.createCallerFactory;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* 3. ROUTER & PROCEDURE (THE IMPORTANT BIT)
|
|
64
|
-
*
|
|
65
|
-
* These are the pieces you use to build your tRPC API. You should import these a lot in the
|
|
66
|
-
* "/src/server/api/routers" directory.
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* This is how you create new routers and sub-routers in your tRPC API.
|
|
71
|
-
*
|
|
72
|
-
* @see https://trpc.io/docs/router
|
|
73
|
-
*/
|
|
74
|
-
export const createTRPCRouter = t.router;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Middleware for timing procedure execution and adding an artificial delay in development.
|
|
78
|
-
*
|
|
79
|
-
* You can remove this if you don't like it, but it can help catch unwanted waterfalls by simulating
|
|
80
|
-
* network latency that would occur in production but not in local development.
|
|
81
|
-
*/
|
|
82
|
-
const timingMiddleware = t.middleware(async ({ next, path }) => {
|
|
83
|
-
const start = Date.now();
|
|
84
|
-
|
|
85
|
-
if (t._config.isDev) {
|
|
86
|
-
// artificial delay in dev
|
|
87
|
-
const waitMs = Math.floor(Math.random() * 400) + 100;
|
|
88
|
-
await new Promise((resolve) => setTimeout(resolve, waitMs));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const result = await next();
|
|
92
|
-
|
|
93
|
-
const end = Date.now();
|
|
94
|
-
console.log(`[TRPC] ${path} took ${end - start}ms to execute`);
|
|
95
|
-
|
|
96
|
-
return result;
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Public (unauthenticated) procedure
|
|
101
|
-
*
|
|
102
|
-
* This is the base piece you use to build new queries and mutations on your tRPC API. It does not
|
|
103
|
-
* guarantee that a user querying is authorized, but you can still access user session data if they
|
|
104
|
-
* are logged in.
|
|
105
|
-
*/
|
|
106
|
-
export const publicProcedure = t.procedure.use(timingMiddleware);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { drizzle } from "drizzle-orm/postgres-js";
|
|
2
|
-
import postgres from "postgres";
|
|
3
|
-
|
|
4
|
-
import { env } from "~/env";
|
|
5
|
-
import * as schema from "./schema";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Cache the database connection in development. This avoids creating a new connection on every HMR
|
|
9
|
-
* update.
|
|
10
|
-
*/
|
|
11
|
-
const globalForDb = globalThis as unknown as {
|
|
12
|
-
conn: postgres.Sql | undefined;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const conn = globalForDb.conn ?? postgres(env.DATABASE_URL);
|
|
16
|
-
if (env.NODE_ENV !== "production") globalForDb.conn = conn;
|
|
17
|
-
|
|
18
|
-
export const db = drizzle(conn, { schema });
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { pgSchema } from "drizzle-orm/pg-core";
|
|
2
|
-
import { env } from "~/env";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Use a dedicated PostgreSQL schema for this app's tables.
|
|
6
|
-
* @see https://orm.drizzle.team/docs/schemas
|
|
7
|
-
*/
|
|
8
|
-
export const schema = pgSchema(env.DATABASE_SCHEMA);
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Helper to create tables in the app's schema.
|
|
12
|
-
* Always use this instead of pgTable to ensure tables are in the correct schema.
|
|
13
|
-
*/
|
|
14
|
-
const createTable = schema.table;
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
@import "tailwindcss";
|
|
2
|
-
@import "tw-animate-css";
|
|
3
|
-
|
|
4
|
-
@custom-variant dark (&:is(.dark *));
|
|
5
|
-
|
|
6
|
-
@theme {
|
|
7
|
-
--font-sans: var(--font-geist-sans), ui-sans-serif, system-ui, sans-serif,
|
|
8
|
-
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
@theme inline {
|
|
12
|
-
--radius-sm: calc(var(--radius) - 4px);
|
|
13
|
-
--radius-md: calc(var(--radius) - 2px);
|
|
14
|
-
--radius-lg: var(--radius);
|
|
15
|
-
--radius-xl: calc(var(--radius) + 4px);
|
|
16
|
-
--color-background: var(--background);
|
|
17
|
-
--color-foreground: var(--foreground);
|
|
18
|
-
--color-card: var(--card);
|
|
19
|
-
--color-card-foreground: var(--card-foreground);
|
|
20
|
-
--color-popover: var(--popover);
|
|
21
|
-
--color-popover-foreground: var(--popover-foreground);
|
|
22
|
-
--color-primary: var(--primary);
|
|
23
|
-
--color-primary-foreground: var(--primary-foreground);
|
|
24
|
-
--color-secondary: var(--secondary);
|
|
25
|
-
--color-secondary-foreground: var(--secondary-foreground);
|
|
26
|
-
--color-muted: var(--muted);
|
|
27
|
-
--color-muted-foreground: var(--muted-foreground);
|
|
28
|
-
--color-accent: var(--accent);
|
|
29
|
-
--color-accent-foreground: var(--accent-foreground);
|
|
30
|
-
--color-destructive: var(--destructive);
|
|
31
|
-
--color-border: var(--border);
|
|
32
|
-
--color-input: var(--input);
|
|
33
|
-
--color-ring: var(--ring);
|
|
34
|
-
--color-chart-1: var(--chart-1);
|
|
35
|
-
--color-chart-2: var(--chart-2);
|
|
36
|
-
--color-chart-3: var(--chart-3);
|
|
37
|
-
--color-chart-4: var(--chart-4);
|
|
38
|
-
--color-chart-5: var(--chart-5);
|
|
39
|
-
--color-sidebar: var(--sidebar);
|
|
40
|
-
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
41
|
-
--color-sidebar-primary: var(--sidebar-primary);
|
|
42
|
-
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
43
|
-
--color-sidebar-accent: var(--sidebar-accent);
|
|
44
|
-
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
45
|
-
--color-sidebar-border: var(--sidebar-border);
|
|
46
|
-
--color-sidebar-ring: var(--sidebar-ring);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
:root {
|
|
50
|
-
--radius: 0.65rem;
|
|
51
|
-
--background: oklch(1 0 0);
|
|
52
|
-
--foreground: oklch(0.141 0.005 285.823);
|
|
53
|
-
--card: oklch(1 0 0);
|
|
54
|
-
--card-foreground: oklch(0.141 0.005 285.823);
|
|
55
|
-
--popover: oklch(1 0 0);
|
|
56
|
-
--popover-foreground: oklch(0.141 0.005 285.823);
|
|
57
|
-
--primary: oklch(0.646 0.222 41.116);
|
|
58
|
-
--primary-foreground: oklch(0.98 0.016 73.684);
|
|
59
|
-
--secondary: oklch(0.967 0.001 286.375);
|
|
60
|
-
--secondary-foreground: oklch(0.21 0.006 285.885);
|
|
61
|
-
--muted: oklch(0.967 0.001 286.375);
|
|
62
|
-
--muted-foreground: oklch(0.552 0.016 285.938);
|
|
63
|
-
--accent: oklch(0.967 0.001 286.375);
|
|
64
|
-
--accent-foreground: oklch(0.21 0.006 285.885);
|
|
65
|
-
--destructive: oklch(0.577 0.245 27.325);
|
|
66
|
-
--border: oklch(0.92 0.004 286.32);
|
|
67
|
-
--input: oklch(0.92 0.004 286.32);
|
|
68
|
-
--ring: oklch(0.75 0.183 55.934);
|
|
69
|
-
--chart-1: oklch(0.837 0.128 66.29);
|
|
70
|
-
--chart-2: oklch(0.705 0.213 47.604);
|
|
71
|
-
--chart-3: oklch(0.646 0.222 41.116);
|
|
72
|
-
--chart-4: oklch(0.553 0.195 38.402);
|
|
73
|
-
--chart-5: oklch(0.47 0.157 37.304);
|
|
74
|
-
--sidebar: oklch(0.985 0 0);
|
|
75
|
-
--sidebar-foreground: oklch(0.141 0.005 285.823);
|
|
76
|
-
--sidebar-primary: oklch(0.646 0.222 41.116);
|
|
77
|
-
--sidebar-primary-foreground: oklch(0.98 0.016 73.684);
|
|
78
|
-
--sidebar-accent: oklch(0.967 0.001 286.375);
|
|
79
|
-
--sidebar-accent-foreground: oklch(0.21 0.006 285.885);
|
|
80
|
-
--sidebar-border: oklch(0.92 0.004 286.32);
|
|
81
|
-
--sidebar-ring: oklch(0.75 0.183 55.934);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.dark {
|
|
85
|
-
--background: oklch(0.141 0.005 285.823);
|
|
86
|
-
--foreground: oklch(0.985 0 0);
|
|
87
|
-
--card: oklch(0.21 0.006 285.885);
|
|
88
|
-
--card-foreground: oklch(0.985 0 0);
|
|
89
|
-
--popover: oklch(0.21 0.006 285.885);
|
|
90
|
-
--popover-foreground: oklch(0.985 0 0);
|
|
91
|
-
--primary: oklch(0.705 0.213 47.604);
|
|
92
|
-
--primary-foreground: oklch(0.98 0.016 73.684);
|
|
93
|
-
--secondary: oklch(0.274 0.006 286.033);
|
|
94
|
-
--secondary-foreground: oklch(0.985 0 0);
|
|
95
|
-
--muted: oklch(0.274 0.006 286.033);
|
|
96
|
-
--muted-foreground: oklch(0.705 0.015 286.067);
|
|
97
|
-
--accent: oklch(0.274 0.006 286.033);
|
|
98
|
-
--accent-foreground: oklch(0.985 0 0);
|
|
99
|
-
--destructive: oklch(0.704 0.191 22.216);
|
|
100
|
-
--border: oklch(1 0 0 / 10%);
|
|
101
|
-
--input: oklch(1 0 0 / 15%);
|
|
102
|
-
--ring: oklch(0.408 0.123 38.172);
|
|
103
|
-
--chart-1: oklch(0.837 0.128 66.29);
|
|
104
|
-
--chart-2: oklch(0.705 0.213 47.604);
|
|
105
|
-
--chart-3: oklch(0.646 0.222 41.116);
|
|
106
|
-
--chart-4: oklch(0.553 0.195 38.402);
|
|
107
|
-
--chart-5: oklch(0.47 0.157 37.304);
|
|
108
|
-
--sidebar: oklch(0.21 0.006 285.885);
|
|
109
|
-
--sidebar-foreground: oklch(0.985 0 0);
|
|
110
|
-
--sidebar-primary: oklch(0.705 0.213 47.604);
|
|
111
|
-
--sidebar-primary-foreground: oklch(0.98 0.016 73.684);
|
|
112
|
-
--sidebar-accent: oklch(0.274 0.006 286.033);
|
|
113
|
-
--sidebar-accent-foreground: oklch(0.985 0 0);
|
|
114
|
-
--sidebar-border: oklch(1 0 0 / 10%);
|
|
115
|
-
--sidebar-ring: oklch(0.408 0.123 38.172);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
@layer base {
|
|
119
|
-
* {
|
|
120
|
-
@apply border-border outline-ring/50;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
body {
|
|
124
|
-
@apply bg-background text-foreground;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defaultShouldDehydrateQuery,
|
|
3
|
-
QueryClient,
|
|
4
|
-
} from "@tanstack/react-query";
|
|
5
|
-
import SuperJSON from "superjson";
|
|
6
|
-
|
|
7
|
-
export const createQueryClient = () =>
|
|
8
|
-
new QueryClient({
|
|
9
|
-
defaultOptions: {
|
|
10
|
-
queries: {
|
|
11
|
-
// With SSR, we usually want to set some default staleTime
|
|
12
|
-
// above 0 to avoid refetching immediately on the client
|
|
13
|
-
staleTime: 30 * 1000,
|
|
14
|
-
},
|
|
15
|
-
dehydrate: {
|
|
16
|
-
serializeData: SuperJSON.serialize,
|
|
17
|
-
shouldDehydrateQuery: (query) =>
|
|
18
|
-
defaultShouldDehydrateQuery(query) ||
|
|
19
|
-
query.state.status === "pending",
|
|
20
|
-
},
|
|
21
|
-
hydrate: {
|
|
22
|
-
deserializeData: SuperJSON.deserialize,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
});
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { QueryClientProvider, type QueryClient } from "@tanstack/react-query";
|
|
4
|
-
import { httpBatchStreamLink, loggerLink } from "@trpc/client";
|
|
5
|
-
import { createTRPCReact } from "@trpc/react-query";
|
|
6
|
-
import { type inferRouterInputs, type inferRouterOutputs } from "@trpc/server";
|
|
7
|
-
import { useState } from "react";
|
|
8
|
-
import SuperJSON from "superjson";
|
|
9
|
-
|
|
10
|
-
import { type AppRouter } from "~/server/api/root";
|
|
11
|
-
import { createQueryClient } from "./query-client";
|
|
12
|
-
|
|
13
|
-
let clientQueryClientSingleton: QueryClient | undefined = undefined;
|
|
14
|
-
const getQueryClient = () => {
|
|
15
|
-
if (typeof window === "undefined") {
|
|
16
|
-
// Server: always make a new query client
|
|
17
|
-
return createQueryClient();
|
|
18
|
-
}
|
|
19
|
-
// Browser: use singleton pattern to keep the same query client
|
|
20
|
-
clientQueryClientSingleton ??= createQueryClient();
|
|
21
|
-
|
|
22
|
-
return clientQueryClientSingleton;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const api = createTRPCReact<AppRouter>();
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Inference helper for inputs.
|
|
29
|
-
*
|
|
30
|
-
* @example type HelloInput = RouterInputs['example']['hello']
|
|
31
|
-
*/
|
|
32
|
-
export type RouterInputs = inferRouterInputs<AppRouter>;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Inference helper for outputs.
|
|
36
|
-
*
|
|
37
|
-
* @example type HelloOutput = RouterOutputs['example']['hello']
|
|
38
|
-
*/
|
|
39
|
-
export type RouterOutputs = inferRouterOutputs<AppRouter>;
|
|
40
|
-
|
|
41
|
-
export function TRPCReactProvider(props: { children: React.ReactNode }) {
|
|
42
|
-
const queryClient = getQueryClient();
|
|
43
|
-
|
|
44
|
-
const [trpcClient] = useState(() =>
|
|
45
|
-
api.createClient({
|
|
46
|
-
links: [
|
|
47
|
-
loggerLink({
|
|
48
|
-
enabled: (op) =>
|
|
49
|
-
process.env.NODE_ENV === "development" ||
|
|
50
|
-
(op.direction === "down" && op.result instanceof Error),
|
|
51
|
-
}),
|
|
52
|
-
httpBatchStreamLink({
|
|
53
|
-
transformer: SuperJSON,
|
|
54
|
-
url: `${getBaseUrl()}/api/trpc`,
|
|
55
|
-
headers: () => {
|
|
56
|
-
const headers = new Headers();
|
|
57
|
-
headers.set("x-trpc-source", "nextjs-react");
|
|
58
|
-
return headers;
|
|
59
|
-
},
|
|
60
|
-
}),
|
|
61
|
-
],
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<QueryClientProvider client={queryClient}>
|
|
67
|
-
<api.Provider client={trpcClient} queryClient={queryClient}>
|
|
68
|
-
{props.children}
|
|
69
|
-
</api.Provider>
|
|
70
|
-
</QueryClientProvider>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function getBaseUrl() {
|
|
75
|
-
if (typeof window !== "undefined") return window.location.origin;
|
|
76
|
-
if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}`;
|
|
77
|
-
return `http://localhost:${process.env.PORT ?? 3000}`;
|
|
78
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import "server-only";
|
|
2
|
-
|
|
3
|
-
import { createHydrationHelpers } from "@trpc/react-query/rsc";
|
|
4
|
-
import { headers } from "next/headers";
|
|
5
|
-
import { cache } from "react";
|
|
6
|
-
|
|
7
|
-
import { createCaller, type AppRouter } from "~/server/api/root";
|
|
8
|
-
import { createTRPCContext } from "~/server/api/trpc";
|
|
9
|
-
import { createQueryClient } from "./query-client";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when
|
|
13
|
-
* handling a tRPC call from a React Server Component.
|
|
14
|
-
*/
|
|
15
|
-
const createContext = cache(async () => {
|
|
16
|
-
const heads = new Headers(await headers());
|
|
17
|
-
heads.set("x-trpc-source", "rsc");
|
|
18
|
-
|
|
19
|
-
return createTRPCContext({
|
|
20
|
-
headers: heads,
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const getQueryClient = cache(createQueryClient);
|
|
25
|
-
const caller = createCaller(createContext);
|
|
26
|
-
|
|
27
|
-
export const { trpc: api, HydrateClient } = createHydrationHelpers<AppRouter>(
|
|
28
|
-
caller,
|
|
29
|
-
getQueryClient
|
|
30
|
-
);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"noUnusedLocals": true,
|
|
5
|
-
"noUnusedParameters": true,
|
|
6
|
-
"allowUnreachableCode": false,
|
|
7
|
-
"allowUnusedLabels": false
|
|
8
|
-
},
|
|
9
|
-
"exclude": [
|
|
10
|
-
"node_modules",
|
|
11
|
-
".next",
|
|
12
|
-
"dist",
|
|
13
|
-
"coverage",
|
|
14
|
-
"**/*.test.ts",
|
|
15
|
-
"**/*.test.tsx",
|
|
16
|
-
"**/*.spec.ts",
|
|
17
|
-
"**/*.spec.tsx",
|
|
18
|
-
"src/**/__tests__/**",
|
|
19
|
-
"tests/**",
|
|
20
|
-
"vitest.config.*",
|
|
21
|
-
"vitest.setup.*"
|
|
22
|
-
]
|
|
23
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Base Options: */
|
|
4
|
-
"esModuleInterop": true,
|
|
5
|
-
"skipLibCheck": true,
|
|
6
|
-
"target": "es2022",
|
|
7
|
-
"allowJs": true,
|
|
8
|
-
"resolveJsonModule": true,
|
|
9
|
-
"moduleDetection": "force",
|
|
10
|
-
"isolatedModules": true,
|
|
11
|
-
"verbatimModuleSyntax": true,
|
|
12
|
-
|
|
13
|
-
/* Strictness */
|
|
14
|
-
"strict": true,
|
|
15
|
-
"noUncheckedIndexedAccess": true,
|
|
16
|
-
"checkJs": true,
|
|
17
|
-
|
|
18
|
-
/* Bundled projects */
|
|
19
|
-
"lib": ["dom", "dom.iterable", "ES2022"],
|
|
20
|
-
"noEmit": true,
|
|
21
|
-
"module": "ESNext",
|
|
22
|
-
"moduleResolution": "Bundler",
|
|
23
|
-
"jsx": "preserve",
|
|
24
|
-
"plugins": [{ "name": "next" }],
|
|
25
|
-
"incremental": true,
|
|
26
|
-
|
|
27
|
-
/* Path Aliases */
|
|
28
|
-
"baseUrl": ".",
|
|
29
|
-
"paths": {
|
|
30
|
-
"~/*": ["./src/*"]
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"include": [
|
|
34
|
-
"next-env.d.ts",
|
|
35
|
-
"**/*.ts",
|
|
36
|
-
"**/*.tsx",
|
|
37
|
-
"**/*.cjs",
|
|
38
|
-
"**/*.js",
|
|
39
|
-
".next/types/**/*.ts"
|
|
40
|
-
],
|
|
41
|
-
"exclude": ["node_modules", "generated"]
|
|
42
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"noUnusedLocals": true,
|
|
5
|
-
"noUnusedParameters": true,
|
|
6
|
-
"allowUnreachableCode": false,
|
|
7
|
-
},
|
|
8
|
-
"include": [
|
|
9
|
-
"**/*.test.ts",
|
|
10
|
-
"**/*.test.tsx",
|
|
11
|
-
"**/*.spec.ts",
|
|
12
|
-
"**/*.spec.tsx",
|
|
13
|
-
"src/**/__tests__/*.ts",
|
|
14
|
-
"src/**/__tests__/*.tsx",
|
|
15
|
-
"src/tests/**/*.ts",
|
|
16
|
-
"tests/**/*.ts",
|
|
17
|
-
"tests/**/*.tsx",
|
|
18
|
-
"vitest.config.*",
|
|
19
|
-
"vitest.setup.*"
|
|
20
|
-
]
|
|
21
|
-
}
|