@batijs/cli 0.0.243 → 0.0.244

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.
Files changed (55) hide show
  1. package/dist/boilerplates/@batijs/drizzle/files/$package.json.js +8 -8
  2. package/dist/boilerplates/@batijs/drizzle/files/database/{db.ts → drizzleDb.ts} +1 -2
  3. package/dist/boilerplates/@batijs/drizzle/files/database/seed.ts +4 -3
  4. package/dist/boilerplates/@batijs/drizzle/files/drizzle.config.ts +1 -1
  5. package/dist/boilerplates/@batijs/drizzle/types/database/drizzleDb.d.ts +1 -0
  6. package/dist/boilerplates/@batijs/express/files/$package.json.js +1 -0
  7. package/dist/boilerplates/@batijs/express/files/express-entry.ts +20 -0
  8. package/dist/boilerplates/@batijs/fastify/files/$package.json.js +1 -0
  9. package/dist/boilerplates/@batijs/fastify/files/fastify-entry.ts +20 -0
  10. package/dist/boilerplates/@batijs/h3/files/$package.json.js +1 -0
  11. package/dist/boilerplates/@batijs/h3/files/h3-entry.ts +20 -0
  12. package/dist/boilerplates/@batijs/hattip/files/$package.json.js +1 -0
  13. package/dist/boilerplates/@batijs/hattip/files/hattip-entry.ts +20 -0
  14. package/dist/boilerplates/@batijs/hono/files/$package.json.js +1 -0
  15. package/dist/boilerplates/@batijs/hono/files/hono-entry.ts +20 -0
  16. package/dist/boilerplates/@batijs/lucia-auth/files/$.env.js +23 -0
  17. package/dist/boilerplates/@batijs/lucia-auth/files/$README.md.js +29 -0
  18. package/dist/boilerplates/@batijs/lucia-auth/files/$package.json.js +133 -0
  19. package/dist/boilerplates/@batijs/lucia-auth/files/database/auth-actions.ts +54 -0
  20. package/dist/boilerplates/@batijs/lucia-auth/files/database/schema/auth.ts +41 -0
  21. package/dist/boilerplates/@batijs/lucia-auth/files/database/sqliteDb.ts +30 -0
  22. package/dist/boilerplates/@batijs/lucia-auth/files/lib/lucia-auth.ts +96 -0
  23. package/dist/boilerplates/@batijs/lucia-auth/files/pages/login/+guard.ts +11 -0
  24. package/dist/boilerplates/@batijs/lucia-auth/files/pages/login/style.css +94 -0
  25. package/dist/boilerplates/@batijs/lucia-auth/files/server/lucia-auth-handlers.ts +344 -0
  26. package/dist/boilerplates/@batijs/lucia-auth/files/vike.d.ts +11 -0
  27. package/dist/boilerplates/@batijs/lucia-auth/types/database/auth-actions.d.ts +9 -0
  28. package/dist/boilerplates/@batijs/lucia-auth/types/database/schema/auth.d.ts +167 -0
  29. package/dist/boilerplates/@batijs/lucia-auth/types/database/sqliteDb.d.ts +2 -0
  30. package/dist/boilerplates/@batijs/lucia-auth/types/lib/lucia-auth.d.ts +43 -0
  31. package/dist/boilerplates/@batijs/lucia-auth/types/pages/login/+guard.d.ts +3 -0
  32. package/dist/boilerplates/@batijs/lucia-auth/types/server/lucia-auth-handlers.d.ts +46 -0
  33. package/dist/boilerplates/@batijs/react/files/layouts/LayoutDefault.tsx +1 -0
  34. package/dist/boilerplates/@batijs/react/files/pages/+config.ts +1 -1
  35. package/dist/boilerplates/@batijs/react-lucia-auth/files/pages/login/+Page.tsx +96 -0
  36. package/dist/boilerplates/@batijs/react-lucia-auth/types/pages/login/+Page.d.ts +2 -0
  37. package/dist/boilerplates/@batijs/shared-server/files/server/create-todo-handler.ts +3 -3
  38. package/dist/boilerplates/@batijs/shared-todo/files/pages/todo/+data.ts +3 -3
  39. package/dist/boilerplates/@batijs/solid/files/layouts/LayoutDefault.tsx +1 -0
  40. package/dist/boilerplates/@batijs/solid/files/pages/+config.ts +1 -1
  41. package/dist/boilerplates/@batijs/solid-lucia-auth/files/pages/login/+Page.tsx +96 -0
  42. package/dist/boilerplates/@batijs/solid-lucia-auth/types/pages/login/+Page.d.ts +2 -0
  43. package/dist/boilerplates/@batijs/telefunc/files/pages/todo/TodoList.telefunc.ts +3 -3
  44. package/dist/boilerplates/@batijs/trpc/files/trpc/server.ts +3 -3
  45. package/dist/boilerplates/@batijs/ts-rest/files/server/ts-rest-handler.ts +3 -3
  46. package/dist/boilerplates/@batijs/vercel/files/$package.json.js +2 -2
  47. package/dist/boilerplates/@batijs/vue/files/layouts/LayoutDefault.vue +2 -0
  48. package/dist/boilerplates/@batijs/vue/files/pages/+config.ts +1 -1
  49. package/dist/boilerplates/@batijs/vue-lucia-auth/files/pages/login/+Page.vue +87 -0
  50. package/dist/boilerplates/boilerplates.json +59 -0
  51. package/dist/index.js +1 -1
  52. package/package.json +5 -5
  53. package/dist/boilerplates/@batijs/drizzle/types/database/db.d.ts +0 -2
  54. /package/dist/boilerplates/@batijs/drizzle/files/database/{schema.ts → schema/todos.ts} +0 -0
  55. /package/dist/boilerplates/@batijs/drizzle/types/database/{schema.d.ts → schema/todos.d.ts} +0 -0
@@ -0,0 +1,167 @@
1
+ export declare const userTable: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
2
+ name: "users";
3
+ schema: undefined;
4
+ columns: {
5
+ id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
6
+ name: "id";
7
+ tableName: "users";
8
+ dataType: "string";
9
+ columnType: "SQLiteText";
10
+ data: string;
11
+ driverParam: string;
12
+ notNull: true;
13
+ hasDefault: false;
14
+ isPrimaryKey: true;
15
+ isAutoincrement: false;
16
+ hasRuntimeDefault: false;
17
+ enumValues: [string, ...string[]];
18
+ baseColumn: never;
19
+ generated: undefined;
20
+ }, object>;
21
+ username: import("drizzle-orm/sqlite-core").SQLiteColumn<{
22
+ name: "username";
23
+ tableName: "users";
24
+ dataType: "string";
25
+ columnType: "SQLiteText";
26
+ data: string;
27
+ driverParam: string;
28
+ notNull: true;
29
+ hasDefault: false;
30
+ isPrimaryKey: false;
31
+ isAutoincrement: false;
32
+ hasRuntimeDefault: false;
33
+ enumValues: [string, ...string[]];
34
+ baseColumn: never;
35
+ generated: undefined;
36
+ }, object>;
37
+ password: import("drizzle-orm/sqlite-core").SQLiteColumn<{
38
+ name: "password";
39
+ tableName: "users";
40
+ dataType: "string";
41
+ columnType: "SQLiteText";
42
+ data: string;
43
+ driverParam: string;
44
+ notNull: false;
45
+ hasDefault: false;
46
+ isPrimaryKey: false;
47
+ isAutoincrement: false;
48
+ hasRuntimeDefault: false;
49
+ enumValues: [string, ...string[]];
50
+ baseColumn: never;
51
+ generated: undefined;
52
+ }, object>;
53
+ };
54
+ dialect: "sqlite";
55
+ }>;
56
+ export declare const oauthAccountTable: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
57
+ name: "oauth_accounts";
58
+ schema: undefined;
59
+ columns: {
60
+ providerId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
61
+ name: "provider_id";
62
+ tableName: "oauth_accounts";
63
+ dataType: "string";
64
+ columnType: "SQLiteText";
65
+ data: string;
66
+ driverParam: string;
67
+ notNull: true;
68
+ hasDefault: false;
69
+ isPrimaryKey: false;
70
+ isAutoincrement: false;
71
+ hasRuntimeDefault: false;
72
+ enumValues: [string, ...string[]];
73
+ baseColumn: never;
74
+ generated: undefined;
75
+ }, object>;
76
+ providerUserId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
77
+ name: "provider_user_id";
78
+ tableName: "oauth_accounts";
79
+ dataType: "number";
80
+ columnType: "SQLiteInteger";
81
+ data: number;
82
+ driverParam: number;
83
+ notNull: true;
84
+ hasDefault: false;
85
+ isPrimaryKey: false;
86
+ isAutoincrement: false;
87
+ hasRuntimeDefault: false;
88
+ enumValues: undefined;
89
+ baseColumn: never;
90
+ generated: undefined;
91
+ }, object>;
92
+ userId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
93
+ name: "user_id";
94
+ tableName: "oauth_accounts";
95
+ dataType: "string";
96
+ columnType: "SQLiteText";
97
+ data: string;
98
+ driverParam: string;
99
+ notNull: true;
100
+ hasDefault: false;
101
+ isPrimaryKey: false;
102
+ isAutoincrement: false;
103
+ hasRuntimeDefault: false;
104
+ enumValues: [string, ...string[]];
105
+ baseColumn: never;
106
+ generated: undefined;
107
+ }, object>;
108
+ };
109
+ dialect: "sqlite";
110
+ }>;
111
+ export declare const sessionTable: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
112
+ name: "sessions";
113
+ schema: undefined;
114
+ columns: {
115
+ id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
116
+ name: "id";
117
+ tableName: "sessions";
118
+ dataType: "string";
119
+ columnType: "SQLiteText";
120
+ data: string;
121
+ driverParam: string;
122
+ notNull: true;
123
+ hasDefault: false;
124
+ isPrimaryKey: true;
125
+ isAutoincrement: false;
126
+ hasRuntimeDefault: false;
127
+ enumValues: [string, ...string[]];
128
+ baseColumn: never;
129
+ generated: undefined;
130
+ }, object>;
131
+ userId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
132
+ name: "user_id";
133
+ tableName: "sessions";
134
+ dataType: "string";
135
+ columnType: "SQLiteText";
136
+ data: string;
137
+ driverParam: string;
138
+ notNull: true;
139
+ hasDefault: false;
140
+ isPrimaryKey: false;
141
+ isAutoincrement: false;
142
+ hasRuntimeDefault: false;
143
+ enumValues: [string, ...string[]];
144
+ baseColumn: never;
145
+ generated: undefined;
146
+ }, object>;
147
+ expiresAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
148
+ name: "expires_at";
149
+ tableName: "sessions";
150
+ dataType: "number";
151
+ columnType: "SQLiteInteger";
152
+ data: number;
153
+ driverParam: number;
154
+ notNull: true;
155
+ hasDefault: false;
156
+ isPrimaryKey: false;
157
+ isAutoincrement: false;
158
+ hasRuntimeDefault: false;
159
+ enumValues: undefined;
160
+ baseColumn: never;
161
+ generated: undefined;
162
+ }, object>;
163
+ };
164
+ dialect: "sqlite";
165
+ }>;
166
+ export type UserItem = typeof userTable.$inferSelect;
167
+ export type UserInsert = typeof userTable.$inferInsert;
@@ -0,0 +1,2 @@
1
+ import { type Database } from "better-sqlite3";
2
+ export declare const sqliteDb: Database;
@@ -0,0 +1,43 @@
1
+ import "dotenv/config";
2
+ import { Lucia } from "lucia";
3
+ import { GitHub } from "arctic";
4
+ /**
5
+ * Initialize Lucia
6
+ *
7
+ * @link {@see https://lucia-auth.com/getting-started/#initialize-lucia}
8
+ */
9
+ export declare const lucia: Lucia<Record<never, never>, {
10
+ username: string;
11
+ }>;
12
+ /**
13
+ * Initialize OAuth provider
14
+ *
15
+ * @link {@see https://lucia-auth.com/guides/oauth/basics#initialize-oauth-provider}
16
+ */
17
+ export declare const github: GitHub;
18
+ /**
19
+ * Define user attributes
20
+ *
21
+ * @link {@see https://lucia-auth.com/basics/users#define-user-attributes}
22
+ */
23
+ declare module "lucia" {
24
+ interface Register {
25
+ Lucia: typeof lucia;
26
+ DatabaseUserAttributes: Omit<DatabaseUser, "id">;
27
+ }
28
+ }
29
+ export interface DatabaseUser {
30
+ id: string;
31
+ username: string;
32
+ password?: string;
33
+ }
34
+ export interface DatabaseOAuthAccount {
35
+ provider_id: string;
36
+ provider_user_id: string;
37
+ userId: string;
38
+ user_id: string;
39
+ }
40
+ export interface GitHubUser {
41
+ id: number;
42
+ login: string;
43
+ }
@@ -0,0 +1,3 @@
1
+ import type { GuardAsync } from "vike/types";
2
+ declare const guard: GuardAsync;
3
+ export { guard };
@@ -0,0 +1,46 @@
1
+ import type { Session, User } from "lucia";
2
+ /**
3
+ * CSRF protection middleware
4
+ *
5
+ * @link {@see https://lucia-auth.com/guides/validate-session-cookies/}
6
+ */
7
+ export declare function luciaCsrfMiddleware<Context extends Record<string | number | symbol, unknown>>(request: Request, _context?: Context): Response | undefined;
8
+ /**
9
+ * Validate session cookies middleware
10
+ *
11
+ * @link {@see https://lucia-auth.com/guides/validate-session-cookies/}
12
+ */
13
+ export declare function luciaAuthMiddleware<Context extends Record<string | number | symbol, unknown>>(request: Request, context: Context & {
14
+ session?: Session | null;
15
+ user?: User | null;
16
+ }): Promise<void>;
17
+ /**
18
+ * Register user handler
19
+ *
20
+ * @link {@see https://lucia-auth.com/guides/email-and-password/basics#register-user}
21
+ */
22
+ export declare function luciaAuthSignupHandler<Context extends Record<string | number | symbol, unknown>>(request: Request, _context?: Context): Promise<Response>;
23
+ /**
24
+ * Sign in user handler
25
+ *
26
+ * @link {@see https://lucia-auth.com/guides/email-and-password/basics#sign-in-user}
27
+ */
28
+ export declare function luciaAuthLoginHandler<Context extends Record<string | number | symbol, unknown>>(request: Request, _context?: Context): Promise<Response>;
29
+ /**
30
+ * Log out user handler
31
+ */
32
+ export declare function luciaAuthLogoutHandler<Context extends Record<string | number | symbol, unknown>>(_request: Request, context: Context & {
33
+ session?: Session | null;
34
+ }): Promise<Response>;
35
+ /**
36
+ * Github OAuth authorization handler
37
+ *
38
+ * @link {@see https://lucia-auth.com/guides/oauth/basics#creating-authorization-url}
39
+ */
40
+ export declare function luciaGithubLoginHandler<Context extends Record<string | number | symbol, unknown>>(_request: Request, _context?: Context): Promise<Response>;
41
+ /**
42
+ * Github OAuth validate callback handler
43
+ *
44
+ * @link {@see https://lucia-auth.com/guides/oauth/basics#validate-callback}
45
+ */
46
+ export declare function luciaGithubCallbackHandler<Context extends Record<string | number | symbol, unknown>>(request: Request, _context?: Context): Promise<Response>;
@@ -28,6 +28,7 @@ export default function LayoutDefault({ children }: { children: React.ReactNode
28
28
  <Link href="/">Welcome</Link>
29
29
  <Link href="/todo">Todo</Link>
30
30
  <Link href="/star-wars">Data Fetching</Link>
31
+ {BATI.has("firebase-auth") || BATI.has("lucia-auth") ? <Link href="/login">Login</Link> : ""}
31
32
  </Sidebar>
32
33
  <Content>{children}</Content>
33
34
  </div>
@@ -7,7 +7,7 @@ import Layout from "../layouts/LayoutDefault.js";
7
7
  export default {
8
8
  Layout,
9
9
  Head,
10
- //# BATI.has("auth0") || BATI.has("firebase-auth") || BATI.has("authjs")
10
+ //# BATI.has("auth0") || BATI.has("firebase-auth") || BATI.has("authjs") || BATI.has("lucia-auth")
11
11
  passToClient: ["user"],
12
12
  // <title>
13
13
  title: "My Vike App",
@@ -0,0 +1,96 @@
1
+ import "./style.css";
2
+ import React, { useState } from "react";
3
+ import { navigate } from "vike/client/router";
4
+
5
+ type ValidationError = { username: string | null; password: string | null; invalid?: string };
6
+
7
+ export default function Page() {
8
+ const [formData, setFormData] = useState({
9
+ username: "",
10
+ password: "",
11
+ });
12
+
13
+ const [error, setError] = useState<ValidationError>({
14
+ username: null,
15
+ password: null,
16
+ });
17
+
18
+ const handleOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
19
+ const { name, value } = e.target;
20
+ setFormData((prev) => ({ ...prev, [name]: value }));
21
+ };
22
+ const handleOnSubmit = async (e: React.MouseEvent<HTMLButtonElement, MouseEvent>, action: "login" | "signup") => {
23
+ e.preventDefault();
24
+ try {
25
+ const response = await fetch(`/api/${action}`, {
26
+ method: "POST",
27
+ body: JSON.stringify(formData),
28
+ headers: { "Content-Type": "application/json" },
29
+ });
30
+ const result = await response.json();
31
+ if ("error" in result) {
32
+ console.error("A validation error has occurred :", result.error);
33
+ setError(result.error);
34
+ } else {
35
+ await navigate("/");
36
+ }
37
+ } catch (err) {
38
+ console.error("An unknown error has occurred :", err);
39
+ }
40
+ };
41
+
42
+ return (
43
+ <div className="form">
44
+ <div className="form-content">
45
+ <header>Login / Sign Up</header>
46
+ <form>
47
+ <div className="field">
48
+ <input
49
+ id="username"
50
+ type="text"
51
+ name="username"
52
+ value={formData.username}
53
+ onChange={handleOnChange}
54
+ placeholder="Username"
55
+ autoComplete="username"
56
+ />
57
+ </div>
58
+ {error.username && <span className="field-error">{error.username}</span>}
59
+
60
+ <div className="field">
61
+ <input
62
+ id="password"
63
+ type="password"
64
+ name="password"
65
+ value={formData.password}
66
+ onChange={handleOnChange}
67
+ placeholder="Password"
68
+ />
69
+ </div>
70
+ {error.password && <span className="field-error">{error.password}</span>}
71
+ {error.invalid && <span className="field-error">{error.invalid}</span>}
72
+
73
+ <div className="field button-group">
74
+ <button type="button" className="button-field signup-button" onClick={(e) => handleOnSubmit(e, "signup")}>
75
+ Sign Up
76
+ </button>
77
+ <button type="submit" className="button-field login-button" onClick={(e) => handleOnSubmit(e, "login")}>
78
+ Login
79
+ </button>
80
+ </div>
81
+ </form>
82
+ </div>
83
+
84
+ <div className="media-options">
85
+ <a href="/api/login/github" className="field github">
86
+ <img
87
+ src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCA0OTYgNTEyJz48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNi4wIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjQgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZD0nTTE2NS45IDM5Ny40YzAgMi0yLjMgMy42LTUuMiAzLjYtMy4zIC4zLTUuNi0xLjMtNS42LTMuNiAwLTIgMi4zLTMuNiA1LjItMy42IDMtLjMgNS42IDEuMyA1LjYgMy42em0tMzEuMS00LjVjLS43IDIgMS4zIDQuMyA0LjMgNC45IDIuNiAxIDUuNiAwIDYuMi0ycy0xLjMtNC4zLTQuMy01LjJjLTIuNi0uNy01LjUgLjMtNi4yIDIuM3ptNDQuMi0xLjdjLTIuOSAuNy00LjkgMi42LTQuNiA0LjkgLjMgMiAyLjkgMy4zIDUuOSAyLjYgMi45LS43IDQuOS0yLjYgNC42LTQuNi0uMy0xLjktMy0zLjItNS45LTIuOXpNMjQ0LjggOEMxMDYuMSA4IDAgMTEzLjMgMCAyNTJjMCAxMTAuOSA2OS44IDIwNS44IDE2OS41IDIzOS4yIDEyLjggMi4zIDE3LjMtNS42IDE3LjMtMTIuMSAwLTYuMi0uMy00MC40LS4zLTYxLjQgMCAwLTcwIDE1LTg0LjctMjkuOCAwIDAtMTEuNC0yOS4xLTI3LjgtMzYuNiAwIDAtMjIuOS0xNS43IDEuNi0xNS40IDAgMCAyNC45IDIgMzguNiAyNS44IDIxLjkgMzguNiA1OC42IDI3LjUgNzIuOSAyMC45IDIuMy0xNiA4LjgtMjcuMSAxNi0zMy43LTU1LjktNi4yLTExMi4zLTE0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+ </a>
93
+ </div>
94
+ </div>
95
+ );
96
+ }
@@ -0,0 +1,2 @@
1
+ import "./style.css";
2
+ export default function Page(): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
- import { db } from "@batijs/drizzle/database/db";
2
- import { todoTable } from "@batijs/drizzle/database/schema";
1
+ import { drizzleDb } from "@batijs/drizzle/database/drizzleDb";
2
+ import { todoTable } from "@batijs/drizzle/database/schema/todos";
3
3
 
4
4
  export async function createTodoHandler<Context extends Record<string | number | symbol, unknown>>(
5
5
  request: Request,
@@ -9,7 +9,7 @@ export async function createTodoHandler<Context extends Record<string | number |
9
9
  const newTodo = (await request.json()) as { text: string };
10
10
 
11
11
  if (BATI.has("drizzle")) {
12
- await db.insert(todoTable).values({ text: newTodo.text });
12
+ await drizzleDb.insert(todoTable).values({ text: newTodo.text });
13
13
  } else {
14
14
  // This is where you'd persist the data
15
15
  console.log("Received new todo", newTodo);
@@ -1,6 +1,6 @@
1
1
  // https://vike.dev/data
2
- import { db } from "@batijs/drizzle/database/db";
3
- import { todoTable } from "@batijs/drizzle/database/schema";
2
+ import { drizzleDb } from "@batijs/drizzle/database/drizzleDb";
3
+ import { todoTable } from "@batijs/drizzle/database/schema/todos";
4
4
  import { todos } from "@batijs/shared-no-db/database/todoItems";
5
5
 
6
6
  export type Data = {
@@ -9,7 +9,7 @@ export type Data = {
9
9
 
10
10
  export default async function data(): Promise<Data> {
11
11
  if (BATI.has("drizzle")) {
12
- const todo = db.select().from(todoTable).all();
12
+ const todo = drizzleDb.select().from(todoTable).all();
13
13
 
14
14
  return { todo };
15
15
  } else {
@@ -22,6 +22,7 @@ export default function LayoutDefault(props: { children?: JSX.Element }) {
22
22
  <Link href="/">Welcome</Link>
23
23
  <Link href="/todo">Todo</Link>
24
24
  <Link href="/star-wars">Data Fetching</Link>
25
+ {BATI.has("firebase-auth") || BATI.has("lucia-auth") ? <Link href="/login">Login</Link> : ""}
25
26
  </Sidebar>
26
27
  <Content>{props.children}</Content>
27
28
  </div>
@@ -7,7 +7,7 @@ import Layout from "../layouts/LayoutDefault.js";
7
7
  export default {
8
8
  Layout,
9
9
  Head,
10
- //# BATI.has("auth0") || BATI.has("firebase-auth") || BATI.has("authjs")
10
+ //# BATI.has("auth0") || BATI.has("firebase-auth") || BATI.has("authjs") || BATI.has("lucia-auth")
11
11
  passToClient: ["user"],
12
12
  // <title>
13
13
  title: "My Vike App",
@@ -0,0 +1,96 @@
1
+ import "./style.css";
2
+ import { createSignal, untrack } from "solid-js";
3
+ import { navigate } from "vike/client/router";
4
+
5
+ type ValidationError = { username: string | null; password: string | null; invalid?: string };
6
+
7
+ export function Page() {
8
+ const [formData, setFormData] = createSignal({
9
+ username: "",
10
+ password: "",
11
+ });
12
+
13
+ const [error, setError] = createSignal<ValidationError>({
14
+ username: null,
15
+ password: null,
16
+ });
17
+
18
+ const handleOnChange = (e: Event) => {
19
+ const { name, value } = e.currentTarget as HTMLInputElement;
20
+ setFormData((prev) => ({ ...prev, [name]: value }));
21
+ };
22
+
23
+ const handleOnSubmit = async (e: Event, action: "login" | "signup") => {
24
+ e.preventDefault();
25
+ try {
26
+ const response = await fetch(`/api/${action}`, {
27
+ method: "POST",
28
+ body: JSON.stringify(untrack(formData)),
29
+ headers: { "Content-Type": "application/json" },
30
+ });
31
+ const result = await response.json();
32
+ if ("error" in result) {
33
+ console.error("A validation error has occurred :", result.error);
34
+ setError(result.error);
35
+ } else {
36
+ await navigate("/");
37
+ }
38
+ } catch (err) {
39
+ console.error("An unknown error has occurred :", err);
40
+ }
41
+ };
42
+ return (
43
+ <div class="form">
44
+ <div class="form-content">
45
+ <header>Login / Sign Up</header>
46
+ <form>
47
+ <div class="field">
48
+ <input
49
+ id="username"
50
+ type="text"
51
+ name="username"
52
+ value={formData().username}
53
+ onChange={handleOnChange}
54
+ placeholder="Username"
55
+ autocomplete="username"
56
+ />
57
+ </div>
58
+ {error().username && <span class="field-error">{error().username}</span>}
59
+
60
+ <div class="field">
61
+ <input
62
+ id="password"
63
+ type="password"
64
+ name="password"
65
+ value={formData().password}
66
+ onChange={handleOnChange}
67
+ placeholder="Password"
68
+ />
69
+ </div>
70
+ {error().password && <span class="field-error">{error().password}</span>}
71
+ {error().invalid && <span class="field-error">{error().invalid}</span>}
72
+
73
+ <div class="field button-group">
74
+ <button type="button" class="button-field signup-button" onClick={(e) => handleOnSubmit(e, "signup")}>
75
+ Sign Up
76
+ </button>
77
+ <button type="submit" class="button-field login-button" onClick={(e) => handleOnSubmit(e, "login")}>
78
+ Login
79
+ </button>
80
+ </div>
81
+ </form>
82
+ </div>
83
+
84
+ <div class="media-options">
85
+ <a href="/api/login/github" class="field github">
86
+ <img
87
+ src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCA0OTYgNTEyJz48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNi4wIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjQgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZD0nTTE2NS45IDM5Ny40YzAgMi0yLjMgMy42LTUuMiAzLjYtMy4zIC4zLTUuNi0xLjMtNS42LTMuNiAwLTIgMi4zLTMuNiA1LjItMy42IDMtLjMgNS42IDEuMyA1LjYgMy42em0tMzEuMS00LjVjLS43IDIgMS4zIDQuMyA0LjMgNC45IDIuNiAxIDUuNiAwIDYuMi0ycy0xLjMtNC4zLTQuMy01LjJjLTIuNi0uNy01LjUgLjMtNi4yIDIuM3ptNDQuMi0xLjdjLTIuOSAuNy00LjkgMi42LTQuNiA0LjkgLjMgMiAyLjkgMy4zIDUuOSAyLjYgMi45LS43IDQuOS0yLjYgNC42LTQuNi0uMy0xLjktMy0zLjItNS45LTIuOXpNMjQ0LjggOEMxMD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MtNC4zIC43em0zMi40IDM1LjZjLTEuNiAxLjMtMSA0LjMgMS4zIDYuMiAyLjMgMi4zIDUuMiAyLjYgNi41IDEgMS4zLTEuMyAuNy00LjMtMS4zLTYuMi0yLjItMi4zLTUuMi0yLjYtNi41LTF6bS0xMS40LTE0LjdjLTEuNiAxLTEuNiAzLjYgMCA1LjkgMS42IDIuMyA0LjMgMy4zIDUuNiAyLjMgMS42LTEuMyAxLjYtMy45IDAtNi4yLTEuNC0yLjMtNC0zLjMtNS42LTJ6Jy8+PC9zdmc+"
88
+ class="github-icon"
89
+ alt=""
90
+ />
91
+ <span>Login with Github</span>
92
+ </a>
93
+ </div>
94
+ </div>
95
+ );
96
+ }
@@ -0,0 +1,2 @@
1
+ import "./style.css";
2
+ export declare function Page(): import("solid-js").JSX.Element;
@@ -1,9 +1,9 @@
1
- import { db } from "@batijs/drizzle/database/db";
2
- import { todoTable } from "@batijs/drizzle/database/schema";
1
+ import { drizzleDb } from "@batijs/drizzle/database/drizzleDb";
2
+ import { todoTable } from "@batijs/drizzle/database/schema/todos";
3
3
 
4
4
  export async function onNewTodo({ text }: { text: string }) {
5
5
  if (BATI.has("drizzle")) {
6
- await db.insert(todoTable).values({ text });
6
+ await drizzleDb.insert(todoTable).values({ text });
7
7
  } else {
8
8
  // This is where you'd persist the data
9
9
  console.log("Received new todo", { text });
@@ -1,5 +1,5 @@
1
- import { db } from "@batijs/drizzle/database/db";
2
- import { todoTable } from "@batijs/drizzle/database/schema";
1
+ import { drizzleDb } from "@batijs/drizzle/database/drizzleDb";
2
+ import { todoTable } from "@batijs/drizzle/database/schema/todos";
3
3
  import { initTRPC } from "@trpc/server";
4
4
 
5
5
  /**
@@ -28,7 +28,7 @@ export const appRouter = router({
28
28
  })
29
29
  .mutation(async (opts) => {
30
30
  if (BATI.has("drizzle")) {
31
- await db.insert(todoTable).values({ text: opts.input });
31
+ await drizzleDb.insert(todoTable).values({ text: opts.input });
32
32
  } else {
33
33
  // This is where you'd persist the data
34
34
  console.log("Received new todo", { text: opts.input });
@@ -1,5 +1,5 @@
1
- import { db } from "@batijs/drizzle/database/db";
2
- import { todoTable } from "@batijs/drizzle/database/schema";
1
+ import { drizzleDb } from "@batijs/drizzle/database/drizzleDb";
2
+ import { todoTable } from "@batijs/drizzle/database/schema/todos";
3
3
  import { fetchRequestHandler, tsr } from "@ts-rest/serverless/fetch";
4
4
  import { contract } from "../ts-rest/contract";
5
5
 
@@ -19,7 +19,7 @@ const router = tsr.router(contract, {
19
19
  },
20
20
  createTodo: async ({ body }) => {
21
21
  if (BATI.has("drizzle")) {
22
- await db.insert(todoTable).values({ text: body.text });
22
+ await drizzleDb.insert(todoTable).values({ text: body.text });
23
23
  } else {
24
24
  // This is where you'd persist the data
25
25
  console.log("Received new todo", { text: body.text });
@@ -43,10 +43,10 @@ var require_package = __commonJS({
43
43
  devDependencies: {
44
44
  "@batijs/compile": "workspace:*",
45
45
  "@types/node": "^18.19.14",
46
- "@vite-plugin-vercel/vike": "^8.0.0",
46
+ "@vite-plugin-vercel/vike": "^8.0.1",
47
47
  vike: "^0.4.183",
48
48
  vite: "^5.4.0",
49
- "vite-plugin-vercel": "^8.0.0"
49
+ "vite-plugin-vercel": "^8.0.1"
50
50
  },
51
51
  dependencies: {
52
52
  "@batijs/core": "workspace:*"
@@ -5,6 +5,8 @@
5
5
  <Link href="/"> Welcome </Link>
6
6
  <Link href="/todo"> Todo </Link>
7
7
  <Link href="/star-wars"> Data Fetching </Link>
8
+ <!-- BATI.has("firebase-auth") || BATI.has("lucia-auth") -->
9
+ <Link href="/login">Login</Link>
8
10
  </Sidebar>
9
11
  <Content><slot /></Content>
10
12
  </div>
@@ -7,7 +7,7 @@ import Layout from "../layouts/LayoutDefault.vue";
7
7
  export default {
8
8
  Layout,
9
9
  Head,
10
- //# BATI.has("auth0") || BATI.has("firebase-auth") || BATI.has("authjs")
10
+ //# BATI.has("auth0") || BATI.has("firebase-auth") || BATI.has("authjs") || BATI.has("lucia-auth")
11
11
  passToClient: ["user"],
12
12
  // <title>
13
13
  title: "My Vike App",