@batijs/cli 0.0.643 → 0.0.645
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/{asset-package.json-Oy4M8AmU.js → asset-package.json-45oDzgS0.js} +1 -0
- package/dist/{asset-package.json-D6e6vjLM.js → asset-package.json-C4csvBBQ.js} +1 -0
- package/dist/{asset-package.json-DsPzKJwr.js → asset-package.json-CDq-96lS.js} +1 -0
- package/dist/{asset-package.json-BBHKZA3A.js → asset-package.json-C_aGwesI.js} +1 -0
- package/dist/asset-package.json-D0EjbpfM.js +50 -0
- package/dist/{asset-package.json-DUzfK1ah.js → asset-package.json-DRdzE2Je.js} +1 -0
- package/dist/{asset-package.json-c4TM2QxI.js → asset-package.json-IZ_nF8HA.js} +1 -0
- package/dist/boilerplates/@batijs/better-auth/bati.config.mjs +48 -0
- package/dist/boilerplates/@batijs/better-auth/files/$TODO.md.js +26 -0
- package/dist/boilerplates/@batijs/better-auth/files/$package.json.js +23 -0
- package/dist/boilerplates/@batijs/better-auth/files/asset-package.json.mjs +48 -0
- package/dist/boilerplates/@batijs/better-auth/files/database/better-auth/migrate.ts +20 -0
- package/dist/boilerplates/@batijs/better-auth/files/database/drizzle/schema/auth.ts +99 -0
- package/dist/boilerplates/@batijs/better-auth/files/database/migrations/$better-auth.sql.js +54 -0
- package/dist/boilerplates/@batijs/better-auth/files/server/better-auth-handler.ts +67 -0
- package/dist/boilerplates/@batijs/better-auth/files/server/better-auth.ts +89 -0
- package/dist/boilerplates/@batijs/better-auth/types/database/better-auth/migrate.d.mts +1 -0
- package/dist/boilerplates/@batijs/better-auth/types/database/drizzle/schema/auth.d.mts +1253 -0
- package/dist/boilerplates/@batijs/better-auth/types/server/better-auth-handler.d.mts +20 -0
- package/dist/boilerplates/@batijs/better-auth/types/server/better-auth.d.mts +7 -0
- package/dist/boilerplates/@batijs/cloudflare/files/$wrangler.jsonc.js +5 -0
- package/dist/boilerplates/@batijs/elysia/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/elysia/files/asset-package.json.mjs +1 -0
- package/dist/boilerplates/@batijs/elysia/files/server/elysia.ts +7 -0
- package/dist/boilerplates/@batijs/express/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/express/files/+server.ts +7 -0
- package/dist/boilerplates/@batijs/express/files/asset-package.json.mjs +1 -0
- package/dist/boilerplates/@batijs/fastify/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/fastify/files/+server.ts +7 -0
- package/dist/boilerplates/@batijs/fastify/files/asset-package.json.mjs +1 -0
- package/dist/boilerplates/@batijs/hono/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/hono/files/asset-package.json.mjs +1 -0
- package/dist/boilerplates/@batijs/hono/files/entry_aws_lambda.ts +2 -4
- package/dist/boilerplates/@batijs/hono/files/server/hono.ts +7 -0
- package/dist/boilerplates/@batijs/hono/types/entry_aws_lambda.d.mts +1 -4
- package/dist/boilerplates/@batijs/hono/types/node_modules/.bun/@types+aws-lambda@8.10.162/node_modules/@types/aws-lambda/index.d.mts +1 -2
- package/dist/boilerplates/@batijs/hono/types/node_modules/.bun/@types+aws-lambda@8.10.162/node_modules/@types/aws-lambda/trigger/api-gateway-proxy.d.mts +1 -18
- package/dist/boilerplates/@batijs/react/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/react/files/asset-package.json.mjs +1 -0
- package/dist/boilerplates/@batijs/react/files/pages/+Layout.tsx +2 -0
- package/dist/boilerplates/@batijs/react/files/pages/+config.ts +1 -1
- package/dist/boilerplates/@batijs/react-better-auth/bati.config.mjs +14 -0
- package/dist/boilerplates/@batijs/react-better-auth/files/components/AuthNav.tsx +34 -0
- package/dist/boilerplates/@batijs/react-better-auth/files/global.d.ts +10 -0
- package/dist/boilerplates/@batijs/react-better-auth/files/pages/account/+Page.tsx +32 -0
- package/dist/boilerplates/@batijs/react-better-auth/files/pages/account/+guard.ts +10 -0
- package/dist/boilerplates/@batijs/react-better-auth/files/pages/login/+Page.tsx +84 -0
- package/dist/boilerplates/@batijs/react-better-auth/files/pages/signup/+Page.tsx +87 -0
- package/dist/boilerplates/@batijs/react-better-auth/types/components/AuthNav.d.mts +4 -0
- package/dist/boilerplates/@batijs/react-better-auth/types/pages/account/+Page.d.mts +4 -0
- package/dist/boilerplates/@batijs/react-better-auth/types/pages/account/+guard.d.mts +6 -0
- package/dist/boilerplates/@batijs/react-better-auth/types/pages/login/+Page.d.mts +4 -0
- package/dist/boilerplates/@batijs/react-better-auth/types/pages/signup/+Page.d.mts +4 -0
- package/dist/boilerplates/@batijs/solid/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/solid/files/asset-package.json.mjs +1 -0
- package/dist/boilerplates/@batijs/solid/files/pages/+Layout.tsx +2 -0
- package/dist/boilerplates/@batijs/solid/files/pages/+config.ts +1 -1
- package/dist/boilerplates/@batijs/solid-better-auth/bati.config.mjs +14 -0
- package/dist/boilerplates/@batijs/solid-better-auth/files/components/AuthNav.tsx +38 -0
- package/dist/boilerplates/@batijs/solid-better-auth/files/global.d.ts +10 -0
- package/dist/boilerplates/@batijs/solid-better-auth/files/pages/account/+Page.tsx +31 -0
- package/dist/boilerplates/@batijs/solid-better-auth/files/pages/account/+guard.ts +10 -0
- package/dist/boilerplates/@batijs/solid-better-auth/files/pages/login/+Page.tsx +86 -0
- package/dist/boilerplates/@batijs/solid-better-auth/files/pages/signup/+Page.tsx +89 -0
- package/dist/boilerplates/@batijs/solid-better-auth/types/components/AuthNav.d.mts +4 -0
- package/dist/boilerplates/@batijs/solid-better-auth/types/pages/account/+Page.d.mts +4 -0
- package/dist/boilerplates/@batijs/solid-better-auth/types/pages/account/+guard.d.mts +6 -0
- package/dist/boilerplates/@batijs/solid-better-auth/types/pages/login/+Page.d.mts +4 -0
- package/dist/boilerplates/@batijs/solid-better-auth/types/pages/signup/+Page.d.mts +4 -0
- package/dist/boilerplates/@batijs/trpc/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/vue/files/pages/+Layout.vue +4 -0
- package/dist/boilerplates/@batijs/vue/files/pages/+config.ts +1 -1
- package/dist/boilerplates/@batijs/vue-better-auth/bati.config.mjs +14 -0
- package/dist/boilerplates/@batijs/vue-better-auth/files/components/AuthNav.vue +24 -0
- package/dist/boilerplates/@batijs/vue-better-auth/files/global.d.ts +10 -0
- package/dist/boilerplates/@batijs/vue-better-auth/files/pages/account/+Page.vue +26 -0
- package/dist/boilerplates/@batijs/vue-better-auth/files/pages/account/+guard.ts +10 -0
- package/dist/boilerplates/@batijs/vue-better-auth/files/pages/login/+Page.vue +65 -0
- package/dist/boilerplates/@batijs/vue-better-auth/files/pages/signup/+Page.vue +54 -0
- package/dist/boilerplates/@batijs/vue-better-auth/types/pages/account/+guard.d.mts +6 -0
- package/dist/boilerplates/boilerplates.json +24 -0
- package/dist/index.js +3 -1
- package/package.json +5 -5
- /package/dist/{asset-package.json-DPPOFRzH.js → asset-package2.json-DPPOFRzH.js} +0 -0
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import "./Layout.css";
|
|
4
4
|
//# BATI.has("tailwindcss")
|
|
5
5
|
import "./tailwind.css";
|
|
6
|
+
import { AuthNav } from "@batijs/solid-better-auth/components/AuthNav";
|
|
6
7
|
import type { JSX } from "solid-js";
|
|
7
8
|
import logoUrl from "../assets/logo.svg";
|
|
8
9
|
import { Link } from "../components/Link";
|
|
@@ -24,6 +25,7 @@ export default function Layout(props: { children?: JSX.Element }) {
|
|
|
24
25
|
<Link href="/">Welcome</Link>
|
|
25
26
|
<Link href="/todo">Todo</Link>
|
|
26
27
|
<Link href="/star-wars">Data Fetching</Link>
|
|
28
|
+
{BATI.has("better-auth") ? <AuthNav /> : null}
|
|
27
29
|
</Sidebar>
|
|
28
30
|
<Content>{props.children}</Content>
|
|
29
31
|
</div>
|
|
@@ -9,7 +9,7 @@ const config: Config = {
|
|
|
9
9
|
title: "My Vike App",
|
|
10
10
|
description: "Demo showcasing Vike",
|
|
11
11
|
|
|
12
|
-
//# BATI.has("auth0") || BATI.has("authjs")
|
|
12
|
+
//# BATI.has("auth0") || BATI.has("authjs") || BATI.has("better-auth")
|
|
13
13
|
passToClient: ["user"],
|
|
14
14
|
extends: [vikeSolid],
|
|
15
15
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region ../../packages/core/dist/config.js
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
if (!e) throw Error(t);
|
|
4
|
+
}
|
|
5
|
+
function t(t) {
|
|
6
|
+
return `enforce` in t && e(t.enforce === `pre` || t.enforce === `post`, `'enforce' must be 'pre' or 'post', was ${t.enforce}`), `if` in t && e(typeof t.if == `function`, `'if' must be a function`), `nextSteps` in t && e(typeof t.nextSteps == `function`, `'nextSteps' must be a function`), `knip` in t && (e(typeof t.knip == `object` && t.knip !== null, `'knip' must be an object`), `entry` in t.knip && e(Array.isArray(t.knip.entry), `'knip.entry' must be an array`), `ignoreDependencies` in t.knip && e(Array.isArray(t.knip.ignoreDependencies), `'knip.ignoreDependencies' must be an array`), `ignore` in t.knip && e(Array.isArray(t.knip.ignore), `'knip.ignore' must be an array`), `vite` in t.knip && e(typeof t.knip.vite == `boolean`, `'knip.vite' must be a boolean`)), `env` in t && e(typeof t.env == `function`, `'env' must be a function of meta`), t;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region bati.config.ts
|
|
10
|
+
var bati_config_default = t({ if(meta) {
|
|
11
|
+
return meta.BATI.has("solid") && meta.BATI.has("better-auth");
|
|
12
|
+
} });
|
|
13
|
+
//#endregion
|
|
14
|
+
export { bati_config_default as default };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createAuthClient } from "better-auth/solid";
|
|
2
|
+
import { Show } from "solid-js";
|
|
3
|
+
import { navigate } from "vike/client/router";
|
|
4
|
+
import { usePageContext } from "vike-solid/usePageContext";
|
|
5
|
+
|
|
6
|
+
const authClient = createAuthClient();
|
|
7
|
+
|
|
8
|
+
export function AuthNav() {
|
|
9
|
+
const pageContext = usePageContext();
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<Show
|
|
13
|
+
when={pageContext.user}
|
|
14
|
+
fallback={
|
|
15
|
+
<>
|
|
16
|
+
<a href="/login">Login</a>
|
|
17
|
+
<a href="/signup">Sign up</a>
|
|
18
|
+
</>
|
|
19
|
+
}
|
|
20
|
+
>
|
|
21
|
+
{(user) => (
|
|
22
|
+
<>
|
|
23
|
+
<span>{user().email}</span>
|
|
24
|
+
<a
|
|
25
|
+
href="/"
|
|
26
|
+
onClick={async (ev) => {
|
|
27
|
+
ev.preventDefault();
|
|
28
|
+
await authClient.signOut();
|
|
29
|
+
await navigate("/");
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
Sign out
|
|
33
|
+
</a>
|
|
34
|
+
</>
|
|
35
|
+
)}
|
|
36
|
+
</Show>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createAuthClient } from "better-auth/solid";
|
|
2
|
+
import { navigate } from "vike/client/router";
|
|
3
|
+
import { usePageContext } from "vike-solid/usePageContext";
|
|
4
|
+
|
|
5
|
+
const authClient = createAuthClient();
|
|
6
|
+
|
|
7
|
+
export default function Page() {
|
|
8
|
+
const pageContext = usePageContext();
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<>
|
|
12
|
+
<h1>Account</h1>
|
|
13
|
+
<p>
|
|
14
|
+
Signed in as <strong>{pageContext.user?.email}</strong>
|
|
15
|
+
</p>
|
|
16
|
+
<button
|
|
17
|
+
type="button"
|
|
18
|
+
onClick={async () => {
|
|
19
|
+
await authClient.signOut();
|
|
20
|
+
await navigate("/");
|
|
21
|
+
}}
|
|
22
|
+
//# BATI.has("tailwindcss")
|
|
23
|
+
class={
|
|
24
|
+
"text-white bg-blue-700 hover:bg-blue-800 focus:ring-2 focus:outline-hidden focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto p-2"
|
|
25
|
+
}
|
|
26
|
+
>
|
|
27
|
+
Sign out
|
|
28
|
+
</button>
|
|
29
|
+
</>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { redirect } from "vike/abort";
|
|
2
|
+
import type { PageContext } from "vike/types";
|
|
3
|
+
|
|
4
|
+
// Runs on the server (and during client-side navigation). `pageContext.user` is populated by
|
|
5
|
+
// `betterAuthSessionMiddleware`; unauthenticated visitors are redirected to the login page.
|
|
6
|
+
export function guard(pageContext: PageContext) {
|
|
7
|
+
if (!pageContext.user) {
|
|
8
|
+
throw redirect("/login");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createAuthClient } from "better-auth/solid";
|
|
2
|
+
import { createSignal, Show } from "solid-js";
|
|
3
|
+
import { navigate } from "vike/client/router";
|
|
4
|
+
|
|
5
|
+
const authClient = createAuthClient();
|
|
6
|
+
|
|
7
|
+
export default function Page() {
|
|
8
|
+
const [email, setEmail] = createSignal("");
|
|
9
|
+
const [password, setPassword] = createSignal("");
|
|
10
|
+
const [error, setError] = createSignal<string | null>(null);
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<>
|
|
14
|
+
<h1>Sign in</h1>
|
|
15
|
+
<form
|
|
16
|
+
onSubmit={async (ev) => {
|
|
17
|
+
ev.preventDefault();
|
|
18
|
+
setError(null);
|
|
19
|
+
const res = await authClient.signIn.email({ email: email(), password: password() });
|
|
20
|
+
if (res.error) {
|
|
21
|
+
setError(res.error.message ?? "Unable to sign in");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
await navigate("/account");
|
|
25
|
+
}}
|
|
26
|
+
>
|
|
27
|
+
<p>
|
|
28
|
+
<input
|
|
29
|
+
type="email"
|
|
30
|
+
aria-label="Email"
|
|
31
|
+
placeholder="Email"
|
|
32
|
+
required
|
|
33
|
+
value={email()}
|
|
34
|
+
onInput={(ev) => setEmail(ev.currentTarget.value)}
|
|
35
|
+
//# BATI.has("tailwindcss")
|
|
36
|
+
class={
|
|
37
|
+
"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 w-full sm:w-auto p-2 mr-1 mb-1"
|
|
38
|
+
}
|
|
39
|
+
/>
|
|
40
|
+
</p>
|
|
41
|
+
<p>
|
|
42
|
+
<input
|
|
43
|
+
type="password"
|
|
44
|
+
aria-label="Password"
|
|
45
|
+
placeholder="Password"
|
|
46
|
+
required
|
|
47
|
+
value={password()}
|
|
48
|
+
onInput={(ev) => setPassword(ev.currentTarget.value)}
|
|
49
|
+
//# BATI.has("tailwindcss")
|
|
50
|
+
class={
|
|
51
|
+
"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 w-full sm:w-auto p-2 mr-1 mb-1"
|
|
52
|
+
}
|
|
53
|
+
/>
|
|
54
|
+
</p>
|
|
55
|
+
<button
|
|
56
|
+
type="submit"
|
|
57
|
+
//# BATI.has("tailwindcss")
|
|
58
|
+
class={
|
|
59
|
+
"text-white bg-blue-700 hover:bg-blue-800 focus:ring-2 focus:outline-hidden focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto p-2"
|
|
60
|
+
}
|
|
61
|
+
>
|
|
62
|
+
Sign in
|
|
63
|
+
</button>
|
|
64
|
+
</form>
|
|
65
|
+
<p>or</p>
|
|
66
|
+
<button
|
|
67
|
+
type="button"
|
|
68
|
+
onClick={async () => {
|
|
69
|
+
await authClient.signIn.social({ provider: "github" });
|
|
70
|
+
}}
|
|
71
|
+
//# BATI.has("tailwindcss")
|
|
72
|
+
class={
|
|
73
|
+
"text-white bg-gray-800 hover:bg-gray-900 focus:ring-2 focus:outline-hidden focus:ring-gray-300 font-medium rounded-lg text-sm w-full sm:w-auto p-2"
|
|
74
|
+
}
|
|
75
|
+
>
|
|
76
|
+
Sign in with GitHub
|
|
77
|
+
</button>
|
|
78
|
+
<Show when={error()}>
|
|
79
|
+
<p role="alert">{error()}</p>
|
|
80
|
+
</Show>
|
|
81
|
+
<p>
|
|
82
|
+
No account? <a href="/signup">Sign up</a>
|
|
83
|
+
</p>
|
|
84
|
+
</>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { createAuthClient } from "better-auth/solid";
|
|
2
|
+
import { createSignal, Show } from "solid-js";
|
|
3
|
+
import { navigate } from "vike/client/router";
|
|
4
|
+
|
|
5
|
+
const authClient = createAuthClient();
|
|
6
|
+
|
|
7
|
+
export default function Page() {
|
|
8
|
+
const [name, setName] = createSignal("");
|
|
9
|
+
const [email, setEmail] = createSignal("");
|
|
10
|
+
const [password, setPassword] = createSignal("");
|
|
11
|
+
const [error, setError] = createSignal<string | null>(null);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
<h1>Sign up</h1>
|
|
16
|
+
<form
|
|
17
|
+
onSubmit={async (ev) => {
|
|
18
|
+
ev.preventDefault();
|
|
19
|
+
setError(null);
|
|
20
|
+
const res = await authClient.signUp.email({ name: name(), email: email(), password: password() });
|
|
21
|
+
if (res.error) {
|
|
22
|
+
setError(res.error.message ?? "Unable to sign up");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
await navigate("/account");
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
<p>
|
|
29
|
+
<input
|
|
30
|
+
type="text"
|
|
31
|
+
aria-label="Name"
|
|
32
|
+
placeholder="Name"
|
|
33
|
+
required
|
|
34
|
+
value={name()}
|
|
35
|
+
onInput={(ev) => setName(ev.currentTarget.value)}
|
|
36
|
+
//# BATI.has("tailwindcss")
|
|
37
|
+
class={
|
|
38
|
+
"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 w-full sm:w-auto p-2 mr-1 mb-1"
|
|
39
|
+
}
|
|
40
|
+
/>
|
|
41
|
+
</p>
|
|
42
|
+
<p>
|
|
43
|
+
<input
|
|
44
|
+
type="email"
|
|
45
|
+
aria-label="Email"
|
|
46
|
+
placeholder="Email"
|
|
47
|
+
required
|
|
48
|
+
value={email()}
|
|
49
|
+
onInput={(ev) => setEmail(ev.currentTarget.value)}
|
|
50
|
+
//# BATI.has("tailwindcss")
|
|
51
|
+
class={
|
|
52
|
+
"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 w-full sm:w-auto p-2 mr-1 mb-1"
|
|
53
|
+
}
|
|
54
|
+
/>
|
|
55
|
+
</p>
|
|
56
|
+
<p>
|
|
57
|
+
<input
|
|
58
|
+
type="password"
|
|
59
|
+
aria-label="Password"
|
|
60
|
+
placeholder="Password (min. 8 characters)"
|
|
61
|
+
required
|
|
62
|
+
minLength={8}
|
|
63
|
+
value={password()}
|
|
64
|
+
onInput={(ev) => setPassword(ev.currentTarget.value)}
|
|
65
|
+
//# BATI.has("tailwindcss")
|
|
66
|
+
class={
|
|
67
|
+
"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 w-full sm:w-auto p-2 mr-1 mb-1"
|
|
68
|
+
}
|
|
69
|
+
/>
|
|
70
|
+
</p>
|
|
71
|
+
<button
|
|
72
|
+
type="submit"
|
|
73
|
+
//# BATI.has("tailwindcss")
|
|
74
|
+
class={
|
|
75
|
+
"text-white bg-blue-700 hover:bg-blue-800 focus:ring-2 focus:outline-hidden focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto p-2"
|
|
76
|
+
}
|
|
77
|
+
>
|
|
78
|
+
Sign up
|
|
79
|
+
</button>
|
|
80
|
+
</form>
|
|
81
|
+
<Show when={error()}>
|
|
82
|
+
<p role="alert">{error()}</p>
|
|
83
|
+
</Show>
|
|
84
|
+
<p>
|
|
85
|
+
Already have an account? <a href="/login">Sign in</a>
|
|
86
|
+
</p>
|
|
87
|
+
</>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { loadPackageJson } from "@batijs/core";
|
|
4
4
|
//#region ../../boilerplates/trpc/dist/files/$package.json.mjs
|
|
5
5
|
async function getPackageJson(props) {
|
|
6
|
-
return (await loadPackageJson(props, await import("../../../../asset-
|
|
6
|
+
return (await loadPackageJson(props, await import("../../../../asset-package2.json-DPPOFRzH.js").then((x) => x.default))).addDependencies(["@trpc/server", "@trpc/client"]);
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
9
|
export { getPackageJson as default };
|
|
@@ -7,12 +7,16 @@
|
|
|
7
7
|
<Link href="/"> Welcome </Link>
|
|
8
8
|
<Link href="/todo"> Todo </Link>
|
|
9
9
|
<Link href="/star-wars"> Data Fetching </Link>
|
|
10
|
+
<!-- BATI.has("better-auth") -->
|
|
11
|
+
<AuthNav />
|
|
10
12
|
</Sidebar>
|
|
11
13
|
<Content><slot /></Content>
|
|
12
14
|
</div>
|
|
13
15
|
</template>
|
|
14
16
|
|
|
15
17
|
<script lang="ts" setup>
|
|
18
|
+
//# BATI.has("better-auth")
|
|
19
|
+
import AuthNav from "../components/AuthNav.vue";
|
|
16
20
|
import Content from "../components/Content.vue";
|
|
17
21
|
import Link from "../components/Link.vue";
|
|
18
22
|
import Logo from "../components/Logo.vue";
|
|
@@ -9,7 +9,7 @@ const config: Config = {
|
|
|
9
9
|
title: "My Vike App",
|
|
10
10
|
description: "Demo showcasing Vike",
|
|
11
11
|
|
|
12
|
-
//# BATI.has("auth0") || BATI.has("authjs")
|
|
12
|
+
//# BATI.has("auth0") || BATI.has("authjs") || BATI.has("better-auth")
|
|
13
13
|
passToClient: ["user"],
|
|
14
14
|
extends: [vikeVue],
|
|
15
15
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region ../../packages/core/dist/config.js
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
if (!e) throw Error(t);
|
|
4
|
+
}
|
|
5
|
+
function t(t) {
|
|
6
|
+
return `enforce` in t && e(t.enforce === `pre` || t.enforce === `post`, `'enforce' must be 'pre' or 'post', was ${t.enforce}`), `if` in t && e(typeof t.if == `function`, `'if' must be a function`), `nextSteps` in t && e(typeof t.nextSteps == `function`, `'nextSteps' must be a function`), `knip` in t && (e(typeof t.knip == `object` && t.knip !== null, `'knip' must be an object`), `entry` in t.knip && e(Array.isArray(t.knip.entry), `'knip.entry' must be an array`), `ignoreDependencies` in t.knip && e(Array.isArray(t.knip.ignoreDependencies), `'knip.ignoreDependencies' must be an array`), `ignore` in t.knip && e(Array.isArray(t.knip.ignore), `'knip.ignore' must be an array`), `vite` in t.knip && e(typeof t.knip.vite == `boolean`, `'knip.vite' must be a boolean`)), `env` in t && e(typeof t.env == `function`, `'env' must be a function of meta`), t;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region bati.config.ts
|
|
10
|
+
var bati_config_default = t({ if(meta) {
|
|
11
|
+
return meta.BATI.has("vue") && meta.BATI.has("better-auth");
|
|
12
|
+
} });
|
|
13
|
+
//#endregion
|
|
14
|
+
export { bati_config_default as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<template v-if="!pageContext.user">
|
|
3
|
+
<a href="/login">Login</a>
|
|
4
|
+
<a href="/signup">Sign up</a>
|
|
5
|
+
</template>
|
|
6
|
+
<template v-else>
|
|
7
|
+
<span>{{ pageContext.user.email }}</span>
|
|
8
|
+
<a href="/" @click.prevent="onSignOut">Sign out</a>
|
|
9
|
+
</template>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script lang="ts" setup>
|
|
13
|
+
import { createAuthClient } from "better-auth/vue";
|
|
14
|
+
import { navigate } from "vike/client/router";
|
|
15
|
+
import { usePageContext } from "vike-vue/usePageContext";
|
|
16
|
+
|
|
17
|
+
const authClient = createAuthClient();
|
|
18
|
+
const pageContext = usePageContext();
|
|
19
|
+
|
|
20
|
+
const onSignOut = async () => {
|
|
21
|
+
await authClient.signOut();
|
|
22
|
+
await navigate("/");
|
|
23
|
+
};
|
|
24
|
+
</script>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<h1>Account</h1>
|
|
3
|
+
<p>
|
|
4
|
+
Signed in as <strong>{{ pageContext.user?.email }}</strong>
|
|
5
|
+
</p>
|
|
6
|
+
<p v-if="pageContext.user?.name">Name: {{ pageContext.user.name }}</p>
|
|
7
|
+
<button :class="buttonClass" type="button" @click="onSignOut">Sign out</button>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script lang="ts" setup>
|
|
11
|
+
import { createAuthClient } from "better-auth/vue";
|
|
12
|
+
import { navigate } from "vike/client/router";
|
|
13
|
+
import { usePageContext } from "vike-vue/usePageContext";
|
|
14
|
+
|
|
15
|
+
const authClient = createAuthClient();
|
|
16
|
+
const pageContext = usePageContext();
|
|
17
|
+
|
|
18
|
+
const buttonClass = BATI.has("tailwindcss")
|
|
19
|
+
? "text-white bg-blue-700 hover:bg-blue-800 focus:ring-2 focus:outline-hidden focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto p-2"
|
|
20
|
+
: "";
|
|
21
|
+
|
|
22
|
+
const onSignOut = async () => {
|
|
23
|
+
await authClient.signOut();
|
|
24
|
+
await navigate("/");
|
|
25
|
+
};
|
|
26
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { redirect } from "vike/abort";
|
|
2
|
+
import type { PageContext } from "vike/types";
|
|
3
|
+
|
|
4
|
+
// Runs on the server (and during client-side navigation). `pageContext.user` is populated by
|
|
5
|
+
// `betterAuthSessionMiddleware`; unauthenticated visitors are redirected to the login page.
|
|
6
|
+
export function guard(pageContext: PageContext) {
|
|
7
|
+
if (!pageContext.user) {
|
|
8
|
+
throw redirect("/login");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<h1>Sign in</h1>
|
|
3
|
+
<form @submit.prevent="onSubmit">
|
|
4
|
+
<p>
|
|
5
|
+
<input
|
|
6
|
+
v-model="email"
|
|
7
|
+
:class="inputClass"
|
|
8
|
+
type="email"
|
|
9
|
+
aria-label="Email"
|
|
10
|
+
placeholder="Email"
|
|
11
|
+
required
|
|
12
|
+
/>
|
|
13
|
+
</p>
|
|
14
|
+
<p>
|
|
15
|
+
<input
|
|
16
|
+
v-model="password"
|
|
17
|
+
:class="inputClass"
|
|
18
|
+
type="password"
|
|
19
|
+
aria-label="Password"
|
|
20
|
+
placeholder="Password"
|
|
21
|
+
required
|
|
22
|
+
/>
|
|
23
|
+
</p>
|
|
24
|
+
<button :class="buttonClass" type="submit">Sign in</button>
|
|
25
|
+
</form>
|
|
26
|
+
<p>or</p>
|
|
27
|
+
<button :class="githubButtonClass" type="button" @click="onGithub">Sign in with GitHub</button>
|
|
28
|
+
<p v-if="error" role="alert">{{ error }}</p>
|
|
29
|
+
<p>No account? <a href="/signup">Sign up</a></p>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<script lang="ts" setup>
|
|
33
|
+
import { createAuthClient } from "better-auth/vue";
|
|
34
|
+
import { navigate } from "vike/client/router";
|
|
35
|
+
import { ref } from "vue";
|
|
36
|
+
|
|
37
|
+
const authClient = createAuthClient();
|
|
38
|
+
const email = ref("");
|
|
39
|
+
const password = ref("");
|
|
40
|
+
const error = ref<string | null>(null);
|
|
41
|
+
|
|
42
|
+
const inputClass = BATI.has("tailwindcss")
|
|
43
|
+
? "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 w-full sm:w-auto p-2 mr-1 mb-1"
|
|
44
|
+
: "";
|
|
45
|
+
const buttonClass = BATI.has("tailwindcss")
|
|
46
|
+
? "text-white bg-blue-700 hover:bg-blue-800 focus:ring-2 focus:outline-hidden focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto p-2"
|
|
47
|
+
: "";
|
|
48
|
+
const githubButtonClass = BATI.has("tailwindcss")
|
|
49
|
+
? "text-white bg-gray-800 hover:bg-gray-900 focus:ring-2 focus:outline-hidden focus:ring-gray-300 font-medium rounded-lg text-sm w-full sm:w-auto p-2"
|
|
50
|
+
: "";
|
|
51
|
+
|
|
52
|
+
const onSubmit = async () => {
|
|
53
|
+
error.value = null;
|
|
54
|
+
const res = await authClient.signIn.email({ email: email.value, password: password.value });
|
|
55
|
+
if (res.error) {
|
|
56
|
+
error.value = res.error.message ?? "Unable to sign in";
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
await navigate("/account");
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const onGithub = async () => {
|
|
63
|
+
await authClient.signIn.social({ provider: "github" });
|
|
64
|
+
};
|
|
65
|
+
</script>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<h1>Sign up</h1>
|
|
3
|
+
<form @submit.prevent="onSubmit">
|
|
4
|
+
<p>
|
|
5
|
+
<input v-model="name" :class="inputClass" type="text" aria-label="Name" placeholder="Name" required />
|
|
6
|
+
</p>
|
|
7
|
+
<p>
|
|
8
|
+
<input v-model="email" :class="inputClass" type="email" aria-label="Email" placeholder="Email" required />
|
|
9
|
+
</p>
|
|
10
|
+
<p>
|
|
11
|
+
<input
|
|
12
|
+
v-model="password"
|
|
13
|
+
:class="inputClass"
|
|
14
|
+
type="password"
|
|
15
|
+
aria-label="Password"
|
|
16
|
+
placeholder="Password (min. 8 characters)"
|
|
17
|
+
minlength="8"
|
|
18
|
+
required
|
|
19
|
+
/>
|
|
20
|
+
</p>
|
|
21
|
+
<button :class="buttonClass" type="submit">Sign up</button>
|
|
22
|
+
</form>
|
|
23
|
+
<p v-if="error" role="alert">{{ error }}</p>
|
|
24
|
+
<p>Already have an account? <a href="/login">Sign in</a></p>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script lang="ts" setup>
|
|
28
|
+
import { createAuthClient } from "better-auth/vue";
|
|
29
|
+
import { navigate } from "vike/client/router";
|
|
30
|
+
import { ref } from "vue";
|
|
31
|
+
|
|
32
|
+
const authClient = createAuthClient();
|
|
33
|
+
const name = ref("");
|
|
34
|
+
const email = ref("");
|
|
35
|
+
const password = ref("");
|
|
36
|
+
const error = ref<string | null>(null);
|
|
37
|
+
|
|
38
|
+
const inputClass = BATI.has("tailwindcss")
|
|
39
|
+
? "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 w-full sm:w-auto p-2 mr-1 mb-1"
|
|
40
|
+
: "";
|
|
41
|
+
const buttonClass = BATI.has("tailwindcss")
|
|
42
|
+
? "text-white bg-blue-700 hover:bg-blue-800 focus:ring-2 focus:outline-hidden focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto p-2"
|
|
43
|
+
: "";
|
|
44
|
+
|
|
45
|
+
const onSubmit = async () => {
|
|
46
|
+
error.value = null;
|
|
47
|
+
const res = await authClient.signUp.email({ name: name.value, email: email.value, password: password.value });
|
|
48
|
+
if (res.error) {
|
|
49
|
+
error.value = res.error.message ?? "Unable to sign up";
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
await navigate("/account");
|
|
53
|
+
};
|
|
54
|
+
</script>
|
|
@@ -17,6 +17,12 @@
|
|
|
17
17
|
"files"
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
|
+
{
|
|
21
|
+
"folder": "@batijs/better-auth",
|
|
22
|
+
"subfolders": [
|
|
23
|
+
"files"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
20
26
|
{
|
|
21
27
|
"folder": "@batijs/biome",
|
|
22
28
|
"subfolders": [
|
|
@@ -171,6 +177,12 @@
|
|
|
171
177
|
"files"
|
|
172
178
|
]
|
|
173
179
|
},
|
|
180
|
+
{
|
|
181
|
+
"folder": "@batijs/react-better-auth",
|
|
182
|
+
"subfolders": [
|
|
183
|
+
"files"
|
|
184
|
+
]
|
|
185
|
+
},
|
|
174
186
|
{
|
|
175
187
|
"folder": "@batijs/react-sentry",
|
|
176
188
|
"subfolders": [
|
|
@@ -220,6 +232,12 @@
|
|
|
220
232
|
"files"
|
|
221
233
|
]
|
|
222
234
|
},
|
|
235
|
+
{
|
|
236
|
+
"folder": "@batijs/solid-better-auth",
|
|
237
|
+
"subfolders": [
|
|
238
|
+
"files"
|
|
239
|
+
]
|
|
240
|
+
},
|
|
223
241
|
{
|
|
224
242
|
"folder": "@batijs/solid-sentry",
|
|
225
243
|
"subfolders": [
|
|
@@ -281,6 +299,12 @@
|
|
|
281
299
|
"files"
|
|
282
300
|
]
|
|
283
301
|
},
|
|
302
|
+
{
|
|
303
|
+
"folder": "@batijs/vue-better-auth",
|
|
304
|
+
"subfolders": [
|
|
305
|
+
"files"
|
|
306
|
+
]
|
|
307
|
+
},
|
|
284
308
|
{
|
|
285
309
|
"folder": "@batijs/vue-sentry",
|
|
286
310
|
"subfolders": [
|