diff --git a/.changeset/warm-lobsters-doubt.md b/.changeset/warm-lobsters-doubt.md
new file mode 100644
index 0000000..31dc7aa
--- /dev/null
+++ b/.changeset/warm-lobsters-doubt.md
@@ -0,0 +1,5 @@
+---
+"create-jd-app": minor
+---
+
+feat: remove prpc & add AuthPC + bump
diff --git a/README.MD b/README.MD
index 6cecda5..ec39e18 100644
--- a/README.MD
+++ b/README.MD
@@ -20,6 +20,6 @@ pnpm create jd-app@latest
All addons are optional, you may select some, you may select all and you may select none.
- [Prisma](https://github.com/prisma/prisma)
-- [pRPC](https://github.com/solidjs-community/mediakit/tree/main/packages/prpc)
+- [AuthPC](https://github.com/solidjs-community/mediakit/tree/main/packages/authpc/solid)
- [TailwindCSS](https://github.com/tailwindlabs/tailwindcss)
- [AuthJS](https://github.com/solidjs-community/mediakit/tree/main/packages/auth)
diff --git a/package.json b/package.json
index 3a74153..8b059cf 100644
--- a/package.json
+++ b/package.json
@@ -69,7 +69,7 @@
},
"keywords": [
"JDev",
- "pRPC",
+ "AuthPC",
"TypeScript",
"Tailwind",
"Solid",
diff --git a/src/helpers/config.ts b/src/helpers/config.ts
index 330aabe..f368ae9 100644
--- a/src/helpers/config.ts
+++ b/src/helpers/config.ts
@@ -5,18 +5,63 @@ import prettier from "prettier";
export const getAppConfig: IUtil = async (ctx) => {
const usePrisma = ctx.installers.includes("Prisma");
- const usePRPC = ctx.installers.includes("pRPC");
+ const useAuthPC = ctx.installers.includes("AuthPC");
const useAuth = ctx.installers.includes("AuthJS");
+ if (useAuthPC) {
+ return await prettier.format(
+ `import { withAuthPC } from "@solid-mediakit/authpc-plugin";
+
+const config = withAuthPC(
+ {
+ ssr: true,${useAuth ? "\n middleware: './src/middleware.ts'," : ""}${
+ usePrisma
+ ? `\n vite: {
+ ssr: {
+ external: ["@prisma/client"],
+ },
+ },`
+ : ""
+ }${
+ ctx.vercel
+ ? `\n server: {
+ preset: 'vercel',
+ },`
+ : ""
+ }
+ },${
+ useAuth
+ ? `\n {
+ auth: "authjs",
+ authCfg: {
+ configName: "authOptions",
+ source: "~/server/auth",
+ },
+ }`
+ : ""
+ }
+);
+
+export default config;
+
+declare module "@solid-mediakit/authpc" {
+ interface Settings {
+ config: typeof config;
+ }
+}
+`,
+ {
+ parser: "typescript",
+ },
+ );
+ }
return await prettier.format(
`import { defineConfig } from "@solidjs/start/config";${
- usePRPC ? `\nimport { prpcVite } from "@solid-mediakit/prpc-plugin";` : ""
- }${
useAuth ? `\nimport { authVite } from "@solid-mediakit/auth-plugin";` : ""
}
export default defineConfig({
ssr: true,${
- usePrisma || usePRPC
+ usePrisma
? `\n vite: {
${
usePrisma
@@ -24,22 +69,6 @@ export default defineConfig({
external: ["@prisma/client"],
},`
: ""
- }${
- usePRPC
- ? `${usePrisma ? "\n" : ""} plugins: [${
- usePRPC ? "prpcVite(), " : ""
- }${
- useAuth
- ? `authVite({
- authOpts:{
- name: "authOptions",
- dir: "~/server/auth"
- },
- redirectTo: "/"
- })`
- : ""
- }],`
- : ""
}
},`
: ""
@@ -61,7 +90,7 @@ export default defineConfig({
export const modifyConfigIfNeeded = async (ctx: ICtx) => {
if (
ctx.vercel ||
- ctx.installers.includes("pRPC") ||
+ ctx.installers.includes("AuthPC") ||
ctx.installers.includes("Prisma")
) {
await fs.writeFile(
diff --git a/src/helpers/packages.ts b/src/helpers/packages.ts
index f8407b0..ae16cfe 100644
--- a/src/helpers/packages.ts
+++ b/src/helpers/packages.ts
@@ -6,13 +6,12 @@ const packages = {
normal: {
// prisma
"@prisma/client": "^5.20.0",
- // prpc
+ // authpc
"@tanstack/solid-query": "^5.59.0",
- "@solid-mediakit/prpc": "^1.3.3",
- "@solid-mediakit/prpc-plugin": "^1.3.4",
+ "@solid-mediakit/authpc": "^1.2.1",
+ "@solid-mediakit/authpc-plugin": "^1.5.2",
// authjs
- "@solid-mediakit/auth": "^3.0.0",
- "@solid-mediakit/auth-plugin": "^1.1.4",
+ "@solid-mediakit/auth": "^3.0.1",
"@auth/core": "0.35.0",
"@auth/prisma-adapter": "^2.6.0",
// tailwind
diff --git a/src/helpers/utils/getAppLocation.ts b/src/helpers/utils/getAppLocation.ts
index be1acef..a0f6402 100644
--- a/src/helpers/utils/getAppLocation.ts
+++ b/src/helpers/utils/getAppLocation.ts
@@ -1,12 +1,12 @@
import type { ICtx } from "~types";
const getAppLocation = (ctx: ICtx) => {
- const usingPRPC = ctx.installers.includes("pRPC");
+ const usingAuthPC = ctx.installers.includes("AuthPC");
const usingAuth = ctx.installers.includes("AuthJS");
- if (usingPRPC && usingAuth)
- return `${ctx.templateDir}/app/with-auth-prpc.tsx`;
- else if (usingPRPC) return `${ctx.templateDir}/app/with-prpc.tsx`;
+ if (usingAuthPC && usingAuth)
+ return `${ctx.templateDir}/app/with-auth-authpc.tsx`;
+ else if (usingAuthPC) return `${ctx.templateDir}/app/with-authpc.tsx`;
return ``;
};
diff --git a/src/helpers/utils/getIndexLocation.ts b/src/helpers/utils/getIndexLocation.ts
index 89f164a..66a53ce 100644
--- a/src/helpers/utils/getIndexLocation.ts
+++ b/src/helpers/utils/getIndexLocation.ts
@@ -1,33 +1,33 @@
import type { ICtx } from "~types";
const getIndexLocation = (ctx: ICtx) => {
- const usingPRPC = ctx.installers.includes("pRPC");
+ const usingAuthPC = ctx.installers.includes("AuthPC");
const usingTw = ctx.installers.includes("TailwindCSS");
const usingAuth = ctx.installers.includes("AuthJS");
- return createFileHelper(usingPRPC, usingTw, usingAuth, ctx);
+ return createFileHelper(usingAuthPC, usingTw, usingAuth, ctx);
};
export default getIndexLocation;
function createFileHelper(
- usingPRPC: boolean,
+ usingAuthPC: boolean,
usingTw: boolean,
usingAuth: boolean,
- ctx: ICtx
+ ctx: ICtx,
) {
- const fileName = usingPRPC ? `prpc` : "";
+ const fileName = usingAuthPC ? `authpc` : "";
let indexFile = "";
- if (usingPRPC && usingTw && usingAuth) {
+ if (usingAuthPC && usingTw && usingAuth) {
indexFile = `with-auth-${fileName}-tw.tsx`;
- } else if (usingPRPC && !usingTw && usingAuth) {
+ } else if (usingAuthPC && !usingTw && usingAuth) {
indexFile = `with-auth-${fileName}.tsx`;
- } else if (usingPRPC && usingTw) {
+ } else if (usingAuthPC && usingTw) {
indexFile = `with-${fileName}-tw.tsx`;
- } else if (usingPRPC && !usingTw) {
+ } else if (usingAuthPC && !usingTw) {
indexFile = `with-${fileName}.tsx`;
} else if (usingAuth && usingTw) {
indexFile = "with-auth-tw.tsx";
- } else if (!usingPRPC && usingTw) {
+ } else if (!usingAuthPC && usingTw) {
indexFile = "with-tw.tsx";
} else if (usingAuth) {
indexFile = "with-auth.tsx";
diff --git a/src/installers/AuthJS/files/app.txt b/src/installers/AuthJS/files/app.txt
index 09908b5..402eabd 100644
--- a/src/installers/AuthJS/files/app.txt
+++ b/src/installers/AuthJS/files/app.txt
@@ -13,7 +13,7 @@ export default function App() {
Create JD APP
- {props.children}
+ {props.children}
)}
diff --git a/src/installers/AuthJS/files/config.txt b/src/installers/AuthJS/files/config.txt
index d36d77c..c501ac7 100644
--- a/src/installers/AuthJS/files/config.txt
+++ b/src/installers/AuthJS/files/config.txt
@@ -4,7 +4,7 @@ import { serverEnv } from "~/env/server";
declare module "@auth/core/types" {
export interface Session {
- user?: DefaultSession["user"];
+ user: DefaultSession["user"];
}
}
diff --git a/src/installers/AuthJS/files/middleware.txt b/src/installers/AuthJS/files/middleware.txt
new file mode 100644
index 0000000..8322a8f
--- /dev/null
+++ b/src/installers/AuthJS/files/middleware.txt
@@ -0,0 +1,9 @@
+import { authMiddleware } from "@solid-mediakit/auth";
+import { createMiddleware } from "@solidjs/start/middleware";
+import { authOptions } from "./server/auth";
+
+const pathsToPreload = ["/"];
+
+export default createMiddleware({
+ onRequest: [authMiddleware(pathsToPreload, authOptions)],
+});
diff --git a/src/installers/AuthJS/files/prisma-config.txt b/src/installers/AuthJS/files/prisma-config.txt
index d45f930..e7d0cfd 100644
--- a/src/installers/AuthJS/files/prisma-config.txt
+++ b/src/installers/AuthJS/files/prisma-config.txt
@@ -6,8 +6,8 @@ import { serverEnv } from "~/env/server";
declare module "@auth/core/types" {
export interface Session {
- user?: {
- id?: string;
+ user: {
+ id: string;
} & DefaultSession["user"];
}
}
diff --git a/src/installers/AuthJS/files/protected.txt b/src/installers/AuthJS/files/protected.txt
deleted file mode 100644
index 633ab58..0000000
--- a/src/installers/AuthJS/files/protected.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-import { protected$ } from "@solid-mediakit/auth";
-import { protectedQuery } from "~/server/user/user.queries";
-
-export default protected$((session$) => {
- const res = protectedQuery(() => ({ hello: "world" }));
- return (
-
-
Protected Page
-
Session: {JSON.stringify(session$)}
-
Response: {JSON.stringify(res.data)}
-
- );
-});
diff --git a/src/installers/AuthJS/index.ts b/src/installers/AuthJS/index.ts
index f624e72..1d83bb7 100644
--- a/src/installers/AuthJS/index.ts
+++ b/src/installers/AuthJS/index.ts
@@ -7,7 +7,6 @@ const config: IInstaller = (ctx) => {
const normal: KeyOrKeyArray<"normal"> = [
"@auth/core",
"@solid-mediakit/auth",
- "@solid-mediakit/auth-plugin",
];
if (usePrisma) {
normal.push("@auth/prisma-adapter");
@@ -25,15 +24,16 @@ const config: IInstaller = (ctx) => {
path: `${__dirname}/files/handler.txt`,
to: `${ctx.userDir}/src/routes/api/auth/[...solidauth].ts`,
},
- !ctx.installers.includes("pRPC")
+ {
+ path: `${__dirname}/files/middleware.txt`,
+ to: `${ctx.userDir}/src/middleware.ts`,
+ },
+ !ctx.installers.includes("AuthPC")
? {
path: `${__dirname}/files/app.txt`,
to: `${ctx.userDir}/src/app.tsx`,
}
- : {
- path: `${__dirname}/files/protected.txt`,
- to: `${ctx.userDir}/src/routes/protected.tsx`,
- },
+ : undefined,
],
env: [
{
diff --git a/src/installers/AuthPC/files/hello.txt b/src/installers/AuthPC/files/hello.txt
new file mode 100644
index 0000000..edb77c6
--- /dev/null
+++ b/src/installers/AuthPC/files/hello.txt
@@ -0,0 +1,14 @@
+import { z } from "zod";
+import { helloCaller } from "../authpc";
+
+export const helloQuery = helloCaller(
+ z.object({
+ hello: z.string(),
+ }),
+ ({ input$, ctx$ }) => {
+ if (input$.hello === "hello") {
+ return ctx$.hello;
+ }
+ return ctx$.world;
+ },
+);
diff --git a/src/installers/AuthPC/files/user.txt b/src/installers/AuthPC/files/user.txt
new file mode 100644
index 0000000..5bd7503
--- /dev/null
+++ b/src/installers/AuthPC/files/user.txt
@@ -0,0 +1,11 @@
+import { z } from "zod";
+import { userCaller } from "../authpc";
+
+export const protectedQuery = userCaller(
+ z.object({
+ hello: z.string(),
+ }),
+ ({ input$, ctx$ }) => {
+ return `this is top secret: ${input$.hello} ${ctx$.user.name}`;
+ }
+);
diff --git a/src/installers/pRPC/index.ts b/src/installers/AuthPC/index.ts
similarity index 85%
rename from src/installers/pRPC/index.ts
rename to src/installers/AuthPC/index.ts
index 16e8b70..e0b0f3a 100644
--- a/src/installers/pRPC/index.ts
+++ b/src/installers/AuthPC/index.ts
@@ -6,8 +6,8 @@ const config: IInstaller = (ctx) => {
return {
pkgs: withPackages({
normal: [
- "@solid-mediakit/prpc",
- "@solid-mediakit/prpc-plugin",
+ "@solid-mediakit/authpc",
+ "@solid-mediakit/authpc-plugin",
"@tanstack/solid-query",
],
}),
@@ -18,7 +18,7 @@ const config: IInstaller = (ctx) => {
},
{
path: `${__dirname}/utils/getBuilder`,
- to: `${ctx.userDir}/src/server/prpc.ts`,
+ to: `${ctx.userDir}/src/server/authpc.ts`,
type: "exec",
},
useAuth
diff --git a/src/installers/pRPC/utils/getBuilder.ts b/src/installers/AuthPC/utils/getBuilder.ts
similarity index 66%
rename from src/installers/pRPC/utils/getBuilder.ts
rename to src/installers/AuthPC/utils/getBuilder.ts
index 9a7c989..6a11c9c 100644
--- a/src/installers/pRPC/utils/getBuilder.ts
+++ b/src/installers/AuthPC/utils/getBuilder.ts
@@ -1,29 +1,29 @@
-import { IUtil } from "~types";
+import type { IUtil } from "~types";
const getBuilder: IUtil = (ctx) => {
const useAuth = ctx.installers.includes("AuthJS");
- return `import { builder$${
+ return `import { createCaller${
useAuth ? ", error$" : ""
- } } from "@solid-mediakit/prpc";${
+ } } from "@solid-mediakit/authpc";${
useAuth
? `\nimport { authOptions } from "./auth";\nimport { getSession } from "@solid-mediakit/auth";`
: ""
}
-export const helloBuilder = builder$()
- .middleware$(() => {
+export const helloCaller = createCaller
+ .use(() => {
return {
hello: 1,
};
})
- .middleware$((ctx) => {
+ .use(({ ctx$ }) => {
return {
- ...ctx,
+ ...ctx$,
world: 2,
};
});${
useAuth
- ? `\n\nexport const userBuilder = builder$().middleware$(async ({ event$ }) => {
+ ? `\n\nexport const userCaller = createCaller.use(async ({ event$ }) => {
const session = await getSession(event$.request, authOptions);
if (!session) {
return error$("Unauthorized", {
diff --git a/src/installers/pRPC/files/hello.txt b/src/installers/pRPC/files/hello.txt
deleted file mode 100644
index b026775..0000000
--- a/src/installers/pRPC/files/hello.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-import { z } from "zod";
-import { helloBuilder } from "../prpc";
-
-export const helloQuery = helloBuilder
- .input(
- z.object({
- hello: z.string(),
- })
- )
- .query$(({ payload, ctx$ }) => {
- if (payload.hello === "hello") {
- return ctx$.hello;
- }
- return ctx$.world;
- }, "myNewQuery");
diff --git a/src/installers/pRPC/files/user.txt b/src/installers/pRPC/files/user.txt
deleted file mode 100644
index fd65542..0000000
--- a/src/installers/pRPC/files/user.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-import { z } from "zod";
-import { userBuilder } from "../prpc";
-
-export const protectedQuery = userBuilder
- .input(
- z.object({
- hello: z.string(),
- })
- )
- .query$(({ payload, ctx$ }) => {
- return `this is top secret: ${payload.hello} ${ctx$.user?.name}`;
- }, "myProtectedQuery");
diff --git a/src/types.ts b/src/types.ts
index c8050f3..432b037 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -56,4 +56,4 @@ export type IUtil = (
passed?: T,
) => string | Promise;
-export type TInstallers = "AuthJS" | "Prisma" | "TailwindCSS" | "pRPC";
+export type TInstallers = "AuthJS" | "Prisma" | "TailwindCSS" | "AuthPC";
diff --git a/template/app/with-auth-prpc.tsx b/template/app/with-auth-authpc.tsx
similarity index 68%
rename from template/app/with-auth-prpc.tsx
rename to template/app/with-auth-authpc.tsx
index b85f8e2..56a3f6a 100644
--- a/template/app/with-auth-prpc.tsx
+++ b/template/app/with-auth-authpc.tsx
@@ -5,8 +5,8 @@ import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start/router";
import { Suspense } from "solid-js";
import { QueryClient } from "@tanstack/solid-query";
+import { AuthPCProvider } from "@solid-mediakit/authpc/provider";
import { SessionProvider } from "@solid-mediakit/auth/client";
-import { PRPCProvider } from "@solid-mediakit/prpc/provider";
export default function App() {
const queryClient = new QueryClient();
@@ -15,13 +15,11 @@ export default function App() {
root={(props) => (
Create JD App
-
-
-
- {props.children}
-
-
-
+
+
+ {props.children}
+
+
)}
>
diff --git a/template/app/with-prpc.tsx b/template/app/with-authpc.tsx
similarity index 71%
rename from template/app/with-prpc.tsx
rename to template/app/with-authpc.tsx
index 47cf56b..6459a56 100644
--- a/template/app/with-prpc.tsx
+++ b/template/app/with-authpc.tsx
@@ -5,7 +5,7 @@ import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start/router";
import { Suspense } from "solid-js";
import { QueryClient } from "@tanstack/solid-query";
-import { PRPCProvider } from "@solid-mediakit/prpc/provider";
+import { AuthPCProvider } from "@solid-mediakit/authpc/provider";
export default function App() {
const queryClient = new QueryClient();
@@ -14,11 +14,9 @@ export default function App() {
root={(props) => (
Create JD App
-
-
- {props.children}
-
-
+
+ {props.children}
+
)}
>
diff --git a/template/index/with-auth-prpc-tw.tsx b/template/index/with-auth-authpc-tw.tsx
similarity index 94%
rename from template/index/with-auth-prpc-tw.tsx
rename to template/index/with-auth-authpc-tw.tsx
index b947599..ba330d9 100644
--- a/template/index/with-auth-prpc-tw.tsx
+++ b/template/index/with-auth-authpc-tw.tsx
@@ -4,7 +4,7 @@ import { type VoidComponent, Match, Switch } from "solid-js";
import { helloQuery } from "~/server/hello/hello.queries";
const Home: VoidComponent = () => {
- const hello = helloQuery(() => ({ hello: "from pRPC" }));
+ const hello = helloQuery(() => ({ hello: "from AuthPC" }));
return (
@@ -35,9 +35,7 @@ const Home: VoidComponent = () => {
-
- {hello.data ?? "Loading pRPC query"}
-
+
{hello.data}
diff --git a/template/index/with-auth-prpc.tsx b/template/index/with-auth-authpc.tsx
similarity index 92%
rename from template/index/with-auth-prpc.tsx
rename to template/index/with-auth-authpc.tsx
index df597f1..5e5c09f 100644
--- a/template/index/with-auth-prpc.tsx
+++ b/template/index/with-auth-authpc.tsx
@@ -5,7 +5,7 @@ import { type VoidComponent, Match, Switch } from "solid-js";
import { helloQuery } from "~/server/hello/hello.queries";
const Home: VoidComponent = () => {
- const hello = helloQuery(() => ({ hello: "from pRPC" }));
+ const hello = helloQuery(() => ({ hello: "from AuthPC" }));
return (
@@ -36,9 +36,7 @@ const Home: VoidComponent = () => {
-
- {hello.data ?? "Loading pRPC query"}
-
+
{hello.data}
diff --git a/template/index/with-prpc-tw.tsx b/template/index/with-authpc-tw.tsx
similarity index 91%
rename from template/index/with-prpc-tw.tsx
rename to template/index/with-authpc-tw.tsx
index ff8005b..19a03c1 100644
--- a/template/index/with-prpc-tw.tsx
+++ b/template/index/with-authpc-tw.tsx
@@ -3,7 +3,7 @@ import { A } from "@solidjs/router";
import { helloQuery } from "~/server/hello/hello.queries";
const Home: VoidComponent = () => {
- const hello = helloQuery(() => ({ hello: "from pRPC" }));
+ const hello = helloQuery(() => ({ hello: "from AuthPC" }));
return (
@@ -33,7 +33,7 @@ const Home: VoidComponent = () => {
- {hello.data ?? "Loading pRPC query"}
+ {hello.data}
);
diff --git a/template/index/with-prpc.tsx b/template/index/with-authpc.tsx
similarity index 91%
rename from template/index/with-prpc.tsx
rename to template/index/with-authpc.tsx
index c21295b..ca02202 100644
--- a/template/index/with-prpc.tsx
+++ b/template/index/with-authpc.tsx
@@ -4,7 +4,7 @@ import styles from "./index.module.css";
import { helloQuery } from "~/server/hello/hello.queries";
const Home: VoidComponent = () => {
- const hello = helloQuery(() => ({ hello: "from pRPC" }));
+ const hello = helloQuery(() => ({ hello: "from AuthPC" }));
return (
@@ -34,7 +34,7 @@ const Home: VoidComponent = () => {
- {hello.data ?? "Loading pRPC query"}
+ {hello.data}
);