@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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RuntimeAdapter, UniversalMiddleware } from "@universal-middleware/core";
|
|
2
|
+
|
|
3
|
+
//#region files/server/better-auth-handler.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Add the Better Auth user to the context.
|
|
6
|
+
* @link {@see https://better-auth.com/docs/concepts/session-management}
|
|
7
|
+
*/
|
|
8
|
+
declare const betterAuthSessionMiddleware: UniversalMiddleware;
|
|
9
|
+
/**
|
|
10
|
+
* Better Auth route
|
|
11
|
+
* @link {@see https://better-auth.com/docs/installation}
|
|
12
|
+
**/
|
|
13
|
+
declare const betterAuthHandler: ((request: Request<unknown, CfProperties<unknown>>, _context: Universal.Context, runtime: RuntimeAdapter) => Promise<Response>) & import("@universal-middleware/core").WithUniversalSymbols<{
|
|
14
|
+
name: string;
|
|
15
|
+
path: string;
|
|
16
|
+
method: ("GET" | "POST")[];
|
|
17
|
+
immutable: false;
|
|
18
|
+
}>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { betterAuthHandler, betterAuthSessionMiddleware };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RuntimeAdapter } from "@universal-middleware/core";
|
|
2
|
+
import { BetterAuthOptions } from "better-auth";
|
|
3
|
+
|
|
4
|
+
//#region files/server/better-auth.d.ts
|
|
5
|
+
declare function getAuthConfig(runtime?: RuntimeAdapter): BetterAuthOptions;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { getAuthConfig };
|
|
@@ -16,6 +16,11 @@ async function getWrangler(props) {
|
|
|
16
16
|
...wrangler.vars,
|
|
17
17
|
...vars
|
|
18
18
|
};
|
|
19
|
+
if (props.meta.BATI.has("better-auth")) {
|
|
20
|
+
wrangler.compatibility_flags ??= [];
|
|
21
|
+
const flags = wrangler.compatibility_flags;
|
|
22
|
+
if (!flags.includes("nodejs_compat")) flags.push("nodejs_compat");
|
|
23
|
+
}
|
|
19
24
|
return wrangler;
|
|
20
25
|
}
|
|
21
26
|
//#endregion
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { loadPackageJson } from "@batijs/core";
|
|
4
4
|
//#region ../../boilerplates/elysia/dist/files/$package.json.mjs
|
|
5
5
|
async function getPackageJson(props) {
|
|
6
|
-
return (await loadPackageJson(props, await import("../../../../asset-package.json-
|
|
6
|
+
return (await loadPackageJson(props, await import("../../../../asset-package.json-45oDzgS0.js").then((x) => x.default))).addDevDependencies(["@types/node", "vite"]).addDependencies([
|
|
7
7
|
"@vikejs/elysia",
|
|
8
8
|
"elysia",
|
|
9
9
|
"vike"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { authjsHandler, authjsSessionMiddleware } from "@batijs/authjs/server/authjs-handler";
|
|
2
|
+
import { betterAuthHandler, betterAuthSessionMiddleware } from "@batijs/better-auth/server/better-auth-handler";
|
|
2
3
|
import { dbMiddleware } from "@batijs/shared-db/server/db-middleware";
|
|
3
4
|
import { createTodoHandler } from "@batijs/shared-server/server/create-todo-handler";
|
|
4
5
|
import { telefuncHandler } from "@batijs/telefunc/server/telefunc-handler";
|
|
@@ -20,6 +21,12 @@ function getApp() {
|
|
|
20
21
|
//# BATI.has("authjs") || BATI.has("auth0")
|
|
21
22
|
// Auth.js route. See https://authjs.dev/getting-started/installation
|
|
22
23
|
authjsHandler,
|
|
24
|
+
//# BATI.has("better-auth")
|
|
25
|
+
// Append Better Auth user to context
|
|
26
|
+
betterAuthSessionMiddleware,
|
|
27
|
+
//# BATI.has("better-auth")
|
|
28
|
+
// Better Auth route. See https://better-auth.com/docs/installation
|
|
29
|
+
betterAuthHandler,
|
|
23
30
|
//# BATI.has("trpc")
|
|
24
31
|
// tRPC route. See https://trpc.io/docs/server/adapters
|
|
25
32
|
trpcHandler("/api/trpc"),
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { loadPackageJson } from "@batijs/core";
|
|
4
4
|
//#region ../../boilerplates/express/dist/files/$package.json.mjs
|
|
5
5
|
async function getPackageJson(props) {
|
|
6
|
-
return (await loadPackageJson(props, await import("../../../../asset-package.json-
|
|
6
|
+
return (await loadPackageJson(props, await import("../../../../asset-package.json-CDq-96lS.js").then((x) => x.default))).addDevDependencies([
|
|
7
7
|
"@types/express",
|
|
8
8
|
"@types/node",
|
|
9
9
|
"vite"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// BATI.has("auth0") || BATI.hasDatabase
|
|
2
2
|
import "dotenv/config";
|
|
3
3
|
import { authjsHandler, authjsSessionMiddleware } from "@batijs/authjs/server/authjs-handler";
|
|
4
|
+
import { betterAuthHandler, betterAuthSessionMiddleware } from "@batijs/better-auth/server/better-auth-handler";
|
|
4
5
|
import { dbMiddleware } from "@batijs/shared-db/server/db-middleware";
|
|
5
6
|
import { createTodoHandler } from "@batijs/shared-server/server/create-todo-handler";
|
|
6
7
|
import { telefuncHandler } from "@batijs/telefunc/server/telefunc-handler";
|
|
@@ -25,6 +26,12 @@ function getHandler() {
|
|
|
25
26
|
//# BATI.has("authjs") || BATI.has("auth0")
|
|
26
27
|
// Auth.js route. See https://authjs.dev/getting-started/installation
|
|
27
28
|
authjsHandler,
|
|
29
|
+
//# BATI.has("better-auth")
|
|
30
|
+
// Append Better Auth user to context
|
|
31
|
+
betterAuthSessionMiddleware,
|
|
32
|
+
//# BATI.has("better-auth")
|
|
33
|
+
// Better Auth route. See https://better-auth.com/docs/installation
|
|
34
|
+
betterAuthHandler,
|
|
28
35
|
//# BATI.has("trpc")
|
|
29
36
|
// tRPC route. See https://trpc.io/docs/server/adapters
|
|
30
37
|
trpcHandler("/api/trpc"),
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { loadPackageJson } from "@batijs/core";
|
|
4
4
|
//#region ../../boilerplates/fastify/dist/files/$package.json.mjs
|
|
5
5
|
async function getPackageJson(props) {
|
|
6
|
-
return (await loadPackageJson(props, await import("../../../../asset-package.json-
|
|
6
|
+
return (await loadPackageJson(props, await import("../../../../asset-package.json-DRdzE2Je.js").then((x) => x.default))).addDevDependencies(["@types/node", "vite"]).addDependencies([
|
|
7
7
|
"@vikejs/fastify",
|
|
8
8
|
"fastify",
|
|
9
9
|
"fastify-raw-body",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// BATI.has("auth0") || BATI.hasDatabase
|
|
2
2
|
import "dotenv/config";
|
|
3
3
|
import { authjsHandler, authjsSessionMiddleware } from "@batijs/authjs/server/authjs-handler";
|
|
4
|
+
import { betterAuthHandler, betterAuthSessionMiddleware } from "@batijs/better-auth/server/better-auth-handler";
|
|
4
5
|
import { dbMiddleware } from "@batijs/shared-db/server/db-middleware";
|
|
5
6
|
import { createTodoHandler } from "@batijs/shared-server/server/create-todo-handler";
|
|
6
7
|
import { telefuncHandler } from "@batijs/telefunc/server/telefunc-handler";
|
|
@@ -32,6 +33,12 @@ async function getHandler() {
|
|
|
32
33
|
//# BATI.has("authjs") || BATI.has("auth0")
|
|
33
34
|
// Auth.js route. See https://authjs.dev/getting-started/installation
|
|
34
35
|
authjsHandler,
|
|
36
|
+
//# BATI.has("better-auth")
|
|
37
|
+
// Append Better Auth user to context
|
|
38
|
+
betterAuthSessionMiddleware,
|
|
39
|
+
//# BATI.has("better-auth")
|
|
40
|
+
// Better Auth route. See https://better-auth.com/docs/installation
|
|
41
|
+
betterAuthHandler,
|
|
35
42
|
//# BATI.has("trpc")
|
|
36
43
|
// tRPC route. See https://trpc.io/docs/server/adapters
|
|
37
44
|
trpcHandler("/api/trpc"),
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { loadPackageJson } from "@batijs/core";
|
|
4
4
|
//#region ../../boilerplates/hono/dist/files/$package.json.mjs
|
|
5
5
|
async function getPackageJson(props) {
|
|
6
|
-
return (await loadPackageJson(props, await import("../../../../asset-package.json-
|
|
6
|
+
return (await loadPackageJson(props, await import("../../../../asset-package.json-C4csvBBQ.js").then((x) => x.default))).addDevDependencies(["@types/node", "vite"]).addDevDependencies(["@types/aws-lambda"], props.meta.BATI.has("aws")).addDependencies([
|
|
7
7
|
"@vikejs/hono",
|
|
8
8
|
"hono",
|
|
9
9
|
"vike"
|
|
@@ -9,7 +9,7 @@ Notes:
|
|
|
9
9
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import type {
|
|
12
|
+
import type { Handler } from "aws-lambda";
|
|
13
13
|
import { Hono } from "hono";
|
|
14
14
|
import type { LambdaContext, LambdaEvent } from "hono/aws-lambda";
|
|
15
15
|
import { handle } from "hono/aws-lambda";
|
|
@@ -24,7 +24,5 @@ type Bindings = {
|
|
|
24
24
|
const lambdaApp = new Hono<{ Bindings: Bindings }>();
|
|
25
25
|
|
|
26
26
|
lambdaApp.route("/", app as Hono);
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
export const handler: Handler<LambdaEvent, APIGatewayProxyResult> = awsHandler;
|
|
27
|
+
export const handler: Handler = handle(lambdaApp);
|
|
30
28
|
/*{ /if }*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { authjsHandler, authjsSessionMiddleware } from "@batijs/authjs/server/authjs-handler";
|
|
2
|
+
import { betterAuthHandler, betterAuthSessionMiddleware } from "@batijs/better-auth/server/better-auth-handler";
|
|
2
3
|
import { dbMiddleware } from "@batijs/shared-db/server/db-middleware";
|
|
3
4
|
import { createTodoHandler } from "@batijs/shared-server/server/create-todo-handler";
|
|
4
5
|
import { telefuncHandler } from "@batijs/telefunc/server/telefunc-handler";
|
|
@@ -20,6 +21,12 @@ function getApp() {
|
|
|
20
21
|
//# BATI.has("authjs") || BATI.has("auth0")
|
|
21
22
|
// Auth.js route. See https://authjs.dev/getting-started/installation
|
|
22
23
|
authjsHandler,
|
|
24
|
+
//# BATI.has("better-auth")
|
|
25
|
+
// Append Better Auth user to context
|
|
26
|
+
betterAuthSessionMiddleware,
|
|
27
|
+
//# BATI.has("better-auth")
|
|
28
|
+
// Better Auth route. See https://better-auth.com/docs/installation
|
|
29
|
+
betterAuthHandler,
|
|
23
30
|
//# BATI.has("trpc")
|
|
24
31
|
// tRPC route. See https://trpc.io/docs/server/adapters
|
|
25
32
|
trpcHandler("/api/trpc"),
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { Handler } from "./node_modules/.bun/@types+aws-lambda@8.10.162/node_modules/@types/aws-lambda/handler.mjs";
|
|
2
|
-
import { APIGatewayProxyResult } from "./node_modules/.bun/@types+aws-lambda@8.10.162/node_modules/@types/aws-lambda/trigger/api-gateway-proxy.mjs";
|
|
3
|
-
import { LambdaEvent } from "hono/aws-lambda";
|
|
4
|
-
|
|
5
2
|
//#region files/entry_aws_lambda.d.ts
|
|
6
|
-
declare const handler: Handler
|
|
3
|
+
declare const handler: Handler;
|
|
7
4
|
//#endregion
|
|
8
5
|
export { handler };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import { Callback, ClientContext, ClientContextClient, ClientContextEnv, CognitoIdentity, Context, Handler, StreamifyHandler } from "./handler.mjs";
|
|
2
|
-
import { APIGatewayProxyResult } from "./trigger/api-gateway-proxy.mjs";
|
|
1
|
+
import { Callback, ClientContext, ClientContextClient, ClientContextEnv, CognitoIdentity, Context, Handler, StreamifyHandler } from "./handler.mjs";
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Works with Lambda Proxy Integration for Rest API or HTTP API integration Payload Format version 1.0
|
|
4
|
-
* @see - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
|
|
5
|
-
*/
|
|
6
|
-
interface APIGatewayProxyResult {
|
|
7
|
-
statusCode: number;
|
|
8
|
-
headers?: {
|
|
9
|
-
[header: string]: boolean | number | string;
|
|
10
|
-
} | undefined;
|
|
11
|
-
multiValueHeaders?: {
|
|
12
|
-
[header: string]: Array<boolean | number | string>;
|
|
13
|
-
} | undefined;
|
|
14
|
-
body: string;
|
|
15
|
-
isBase64Encoded?: boolean | undefined;
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
export { APIGatewayProxyResult };
|
|
1
|
+
export { };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { loadPackageJson } from "@batijs/core";
|
|
4
4
|
//#region ../../boilerplates/react/dist/files/$package.json.mjs
|
|
5
5
|
async function getPackageJson(props) {
|
|
6
|
-
return (await loadPackageJson(props, await import("../../../../asset-package.json-
|
|
6
|
+
return (await loadPackageJson(props, await import("../../../../asset-package.json-IZ_nF8HA.js").then((x) => x.default))).addDevDependencies([
|
|
7
7
|
"vite",
|
|
8
8
|
"@vitejs/plugin-react",
|
|
9
9
|
"@types/react",
|
|
@@ -18,6 +18,7 @@ var package_default = {
|
|
|
18
18
|
"@babel/plugin-transform-react-jsx": "^7.29.7",
|
|
19
19
|
"@batijs/compile": "workspace:*",
|
|
20
20
|
"@batijs/core": "workspace:*",
|
|
21
|
+
"@batijs/react-better-auth": "workspace:*",
|
|
21
22
|
"@batijs/shared-todo": "workspace:*",
|
|
22
23
|
"@batijs/telefunc": "workspace:*",
|
|
23
24
|
"@batijs/trpc": "workspace:*",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "./Layout.css";
|
|
2
2
|
//# BATI.has("tailwindcss")
|
|
3
3
|
import "./tailwind.css";
|
|
4
|
+
import { AuthNav } from "@batijs/react-better-auth/components/AuthNav";
|
|
4
5
|
import logoUrl from "../assets/logo.svg";
|
|
5
6
|
import { Link } from "../components/Link";
|
|
6
7
|
|
|
@@ -27,6 +28,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {
|
|
|
27
28
|
<Link href="/">Welcome</Link>
|
|
28
29
|
<Link href="/todo">Todo</Link>
|
|
29
30
|
<Link href="/star-wars">Data Fetching</Link>
|
|
31
|
+
{BATI.has("better-auth") ? <AuthNav /> : null}
|
|
30
32
|
</Sidebar>
|
|
31
33
|
<Content>{children}</Content>
|
|
32
34
|
</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: [vikeReact],
|
|
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("react") && meta.BATI.has("better-auth");
|
|
12
|
+
} });
|
|
13
|
+
//#endregion
|
|
14
|
+
export { bati_config_default as default };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createAuthClient } from "better-auth/react";
|
|
2
|
+
import { navigate } from "vike/client/router";
|
|
3
|
+
import { usePageContext } from "vike-react/usePageContext";
|
|
4
|
+
|
|
5
|
+
const authClient = createAuthClient();
|
|
6
|
+
|
|
7
|
+
export function AuthNav() {
|
|
8
|
+
const { user } = usePageContext();
|
|
9
|
+
|
|
10
|
+
if (!user) {
|
|
11
|
+
return (
|
|
12
|
+
<>
|
|
13
|
+
<a href="/login">Login</a>
|
|
14
|
+
<a href="/signup">Sign up</a>
|
|
15
|
+
</>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<>
|
|
21
|
+
<span>{user.email}</span>
|
|
22
|
+
<a
|
|
23
|
+
href="/"
|
|
24
|
+
onClick={async (ev) => {
|
|
25
|
+
ev.preventDefault();
|
|
26
|
+
await authClient.signOut();
|
|
27
|
+
await navigate("/");
|
|
28
|
+
}}
|
|
29
|
+
>
|
|
30
|
+
Sign out
|
|
31
|
+
</a>
|
|
32
|
+
</>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createAuthClient } from "better-auth/react";
|
|
2
|
+
import { navigate } from "vike/client/router";
|
|
3
|
+
import { usePageContext } from "vike-react/usePageContext";
|
|
4
|
+
|
|
5
|
+
const authClient = createAuthClient();
|
|
6
|
+
|
|
7
|
+
export default function Page() {
|
|
8
|
+
const { user } = usePageContext();
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<>
|
|
12
|
+
<h1>Account</h1>
|
|
13
|
+
<p>
|
|
14
|
+
Signed in as <strong>{user?.email}</strong>
|
|
15
|
+
</p>
|
|
16
|
+
{user?.name ? <p>Name: {user.name}</p> : null}
|
|
17
|
+
<button
|
|
18
|
+
type="button"
|
|
19
|
+
onClick={async () => {
|
|
20
|
+
await authClient.signOut();
|
|
21
|
+
await navigate("/");
|
|
22
|
+
}}
|
|
23
|
+
//# BATI.has("tailwindcss")
|
|
24
|
+
className={
|
|
25
|
+
"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"
|
|
26
|
+
}
|
|
27
|
+
>
|
|
28
|
+
Sign out
|
|
29
|
+
</button>
|
|
30
|
+
</>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -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,84 @@
|
|
|
1
|
+
import { createAuthClient } from "better-auth/react";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { navigate } from "vike/client/router";
|
|
4
|
+
|
|
5
|
+
const authClient = createAuthClient();
|
|
6
|
+
|
|
7
|
+
export default function Page() {
|
|
8
|
+
const [email, setEmail] = useState("");
|
|
9
|
+
const [password, setPassword] = useState("");
|
|
10
|
+
const [error, setError] = useState<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, 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
|
+
onChange={(ev) => setEmail(ev.target.value)}
|
|
35
|
+
//# BATI.has("tailwindcss")
|
|
36
|
+
className={
|
|
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
|
+
onChange={(ev) => setPassword(ev.target.value)}
|
|
49
|
+
//# BATI.has("tailwindcss")
|
|
50
|
+
className={
|
|
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
|
+
className={
|
|
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
|
+
className={
|
|
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
|
+
{error ? <p role="alert">{error}</p> : null}
|
|
79
|
+
<p>
|
|
80
|
+
No account? <a href="/signup">Sign up</a>
|
|
81
|
+
</p>
|
|
82
|
+
</>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createAuthClient } from "better-auth/react";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { navigate } from "vike/client/router";
|
|
4
|
+
|
|
5
|
+
const authClient = createAuthClient();
|
|
6
|
+
|
|
7
|
+
export default function Page() {
|
|
8
|
+
const [name, setName] = useState("");
|
|
9
|
+
const [email, setEmail] = useState("");
|
|
10
|
+
const [password, setPassword] = useState("");
|
|
11
|
+
const [error, setError] = useState<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, email, 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
|
+
onChange={(ev) => setName(ev.target.value)}
|
|
36
|
+
//# BATI.has("tailwindcss")
|
|
37
|
+
className={
|
|
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
|
+
onChange={(ev) => setEmail(ev.target.value)}
|
|
50
|
+
//# BATI.has("tailwindcss")
|
|
51
|
+
className={
|
|
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
|
+
onChange={(ev) => setPassword(ev.target.value)}
|
|
65
|
+
//# BATI.has("tailwindcss")
|
|
66
|
+
className={
|
|
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
|
+
className={
|
|
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
|
+
{error ? <p role="alert">{error}</p> : null}
|
|
82
|
+
<p>
|
|
83
|
+
Already have an account? <a href="/login">Sign in</a>
|
|
84
|
+
</p>
|
|
85
|
+
</>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { loadPackageJson } from "@batijs/core";
|
|
4
4
|
//#region ../../boilerplates/solid/dist/files/$package.json.mjs
|
|
5
5
|
async function getPackageJson(props) {
|
|
6
|
-
return (await loadPackageJson(props, await import("../../../../asset-package.json-
|
|
6
|
+
return (await loadPackageJson(props, await import("../../../../asset-package.json-C_aGwesI.js").then((x) => x.default))).addDevDependencies(["vite", "vite-plugin-solid"]).addDependencies([
|
|
7
7
|
"solid-js",
|
|
8
8
|
"vike-solid",
|
|
9
9
|
"vike"
|
|
@@ -16,6 +16,7 @@ var package_default = {
|
|
|
16
16
|
"@batijs/compile": "workspace:*",
|
|
17
17
|
"@batijs/core": "workspace:*",
|
|
18
18
|
"@batijs/shared-todo": "workspace:*",
|
|
19
|
+
"@batijs/solid-better-auth": "workspace:*",
|
|
19
20
|
"@batijs/telefunc": "workspace:*",
|
|
20
21
|
"@batijs/trpc": "workspace:*",
|
|
21
22
|
"@batijs/ts-rest": "workspace:*",
|