@batijs/cli 0.0.444 → 0.0.445

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 (122) hide show
  1. package/dist/boilerplates/@batijs/auth0/files/$.env.js +1 -1
  2. package/dist/boilerplates/@batijs/auth0/files/$README.md.js +1 -1
  3. package/dist/boilerplates/@batijs/authjs/files/$package.json.js +1 -1
  4. package/dist/boilerplates/@batijs/aws/files/$README.md.js +1 -1
  5. package/dist/boilerplates/@batijs/aws/files/$package.json.js +1 -1
  6. package/dist/boilerplates/@batijs/aws/files/$tsconfig.json.js +1 -1
  7. package/dist/boilerplates/@batijs/biome/files/$package.json.js +1 -1
  8. package/dist/boilerplates/@batijs/cloudflare/files/$package.json.js +1 -1
  9. package/dist/boilerplates/@batijs/cloudflare/files/$tsconfig.json.js +1 -1
  10. package/dist/boilerplates/@batijs/cloudflare/files/$vite.config.ts.js +1 -1
  11. package/dist/boilerplates/@batijs/compiled/files/$package.json.js +1 -1
  12. package/dist/boilerplates/@batijs/compiled/files/$vite.config.ts.js +1 -1
  13. package/dist/boilerplates/@batijs/d1/files/$README.md.js +1 -1
  14. package/dist/boilerplates/@batijs/d1/files/$package.json.js +1 -1
  15. package/dist/boilerplates/@batijs/d1/files/$tsconfig.json.js +1 -1
  16. package/dist/boilerplates/@batijs/d1/files/$wrangler.toml.js +1 -1
  17. package/dist/boilerplates/@batijs/d1-sqlite/files/$package.json.js +1 -7
  18. package/dist/boilerplates/@batijs/drizzle/files/$.env.js +1 -1
  19. package/dist/boilerplates/@batijs/drizzle/files/$README.md.js +1 -1
  20. package/dist/boilerplates/@batijs/drizzle/files/$package.json.js +1 -13
  21. package/dist/boilerplates/@batijs/eslint/files/$package.json.js +1 -1
  22. package/dist/boilerplates/@batijs/express/files/$package.json.js +1 -1
  23. package/dist/boilerplates/@batijs/express/files/express-entry.ts +0 -24
  24. package/dist/boilerplates/@batijs/fastify/files/$package.json.js +1 -1
  25. package/dist/boilerplates/@batijs/fastify/files/fastify-entry.ts +0 -24
  26. package/dist/boilerplates/@batijs/firebase-auth/files/$.env.js +1 -1
  27. package/dist/boilerplates/@batijs/firebase-auth/files/$README.md.js +1 -1
  28. package/dist/boilerplates/@batijs/firebase-auth/files/$package.json.js +1 -1
  29. package/dist/boilerplates/@batijs/google-analytics/files/$.env.js +1 -1
  30. package/dist/boilerplates/@batijs/h3/files/$package.json.js +1 -1
  31. package/dist/boilerplates/@batijs/h3/files/h3-entry.ts +0 -24
  32. package/dist/boilerplates/@batijs/hattip/files/$package.json.js +1 -1
  33. package/dist/boilerplates/@batijs/hattip/files/hattip-entry.ts +0 -24
  34. package/dist/boilerplates/@batijs/hono/files/$package.json.js +1 -1
  35. package/dist/boilerplates/@batijs/hono/files/$vite.config.ts.js +1 -1
  36. package/dist/boilerplates/@batijs/hono/files/hono-entry.ts +0 -24
  37. package/dist/boilerplates/@batijs/mantine/files/$README.md.js +1 -1
  38. package/dist/boilerplates/@batijs/mantine/files/$package.json.js +1 -1
  39. package/dist/boilerplates/@batijs/panda-css/files/$package.json.js +1 -1
  40. package/dist/boilerplates/@batijs/pnpm/files/$pnpm-workspace.yaml.js +1 -1
  41. package/dist/boilerplates/@batijs/prettier/files/$package.json.js +1 -1
  42. package/dist/boilerplates/@batijs/prisma/files/$.env.js +1 -1
  43. package/dist/boilerplates/@batijs/prisma/files/$README.md.js +1 -1
  44. package/dist/boilerplates/@batijs/prisma/files/$package.json.js +1 -1
  45. package/dist/boilerplates/@batijs/react/files/$README.md.js +1 -1
  46. package/dist/boilerplates/@batijs/react/files/$package.json.js +1 -1
  47. package/dist/boilerplates/@batijs/react/files/$tsconfig.json.js +1 -1
  48. package/dist/boilerplates/@batijs/react/files/$vite.config.ts.js +1 -1
  49. package/dist/boilerplates/@batijs/react/files/layouts/LayoutDefault.tsx +1 -1
  50. package/dist/boilerplates/@batijs/react/files/pages/+config.ts +1 -1
  51. package/dist/boilerplates/@batijs/react-sentry/files/$package.json.js +1 -1
  52. package/dist/boilerplates/@batijs/sentry/files/$.env.js +1 -1
  53. package/dist/boilerplates/@batijs/sentry/files/$README.md.js +1 -1
  54. package/dist/boilerplates/@batijs/sentry/files/$package.json.js +1 -1
  55. package/dist/boilerplates/@batijs/sentry/files/$vite.config.ts.js +1 -1
  56. package/dist/boilerplates/@batijs/sentry/files/pages/$+client.ts.js +1 -1
  57. package/dist/boilerplates/@batijs/shadcn-ui/files/$README.md.js +1 -1
  58. package/dist/boilerplates/@batijs/shadcn-ui/files/$package.json.js +1 -1
  59. package/dist/boilerplates/@batijs/shadcn-ui/files/$tsconfig.json.js +1 -1
  60. package/dist/boilerplates/@batijs/shadcn-ui/files/$vite.config.ts.js +1 -1
  61. package/dist/boilerplates/@batijs/shared/files/$README.md.js +1 -1
  62. package/dist/boilerplates/@batijs/shared-server/files/$package.json.js +1 -1
  63. package/dist/boilerplates/@batijs/solid/files/$README.md.js +1 -1
  64. package/dist/boilerplates/@batijs/solid/files/$package.json.js +1 -1
  65. package/dist/boilerplates/@batijs/solid/files/$tsconfig.json.js +1 -1
  66. package/dist/boilerplates/@batijs/solid/files/$vite.config.ts.js +1 -1
  67. package/dist/boilerplates/@batijs/solid/files/layouts/LayoutDefault.tsx +1 -1
  68. package/dist/boilerplates/@batijs/solid/files/pages/+config.ts +1 -1
  69. package/dist/boilerplates/@batijs/solid-sentry/files/$package.json.js +1 -1
  70. package/dist/boilerplates/@batijs/sqlite/files/$.env.js +1 -1
  71. package/dist/boilerplates/@batijs/sqlite/files/$README.md.js +1 -1
  72. package/dist/boilerplates/@batijs/sqlite/files/$package.json.js +1 -13
  73. package/dist/boilerplates/@batijs/sqlite/files/database/sqlite/schema/all.ts +0 -2
  74. package/dist/boilerplates/@batijs/sqlite/types/database/sqlite/schema/all.d.ts +0 -1
  75. package/dist/boilerplates/@batijs/tailwindcss/files/$package.json.js +1 -1
  76. package/dist/boilerplates/@batijs/tailwindcss/files/$vite.config.ts.js +1 -1
  77. package/dist/boilerplates/@batijs/telefunc/files/$package.json.js +1 -1
  78. package/dist/boilerplates/@batijs/telefunc/files/$vite.config.ts.js +1 -1
  79. package/dist/boilerplates/@batijs/trpc/files/$package.json.js +1 -1
  80. package/dist/boilerplates/@batijs/ts-rest/files/$package.json.js +1 -1
  81. package/dist/boilerplates/@batijs/vercel/files/$package.json.js +1 -1
  82. package/dist/boilerplates/@batijs/vercel/files/$tsconfig.json.js +1 -1
  83. package/dist/boilerplates/@batijs/vercel/files/$vite.config.ts.js +1 -1
  84. package/dist/boilerplates/@batijs/vercel/files/pages/$+config.ts.js +1 -1
  85. package/dist/boilerplates/@batijs/vue/files/$README.md.js +1 -1
  86. package/dist/boilerplates/@batijs/vue/files/$package.json.js +1 -1
  87. package/dist/boilerplates/@batijs/vue/files/$tsconfig.json.js +1 -1
  88. package/dist/boilerplates/@batijs/vue/files/$vite.config.ts.js +1 -1
  89. package/dist/boilerplates/@batijs/vue/files/layouts/LayoutDefault.vue +1 -1
  90. package/dist/boilerplates/@batijs/vue/files/pages/+config.ts +1 -1
  91. package/dist/boilerplates/@batijs/vue-sentry/files/$package.json.js +1 -1
  92. package/dist/boilerplates/boilerplates.json +0 -59
  93. package/dist/{chunk-HYBBK3CW.js → chunk-YO6CY4MA.js} +2 -2
  94. package/dist/index.js +17 -46
  95. package/package.json +5 -5
  96. package/dist/boilerplates/@batijs/d1-sqlite/files/database/d1/queries/lucia-auth.ts +0 -29
  97. package/dist/boilerplates/@batijs/d1-sqlite/files/database/migrations/lucia-auth.sql +0 -20
  98. package/dist/boilerplates/@batijs/d1-sqlite/types/database/d1/queries/lucia-auth.d.ts +0 -5
  99. package/dist/boilerplates/@batijs/drizzle/files/database/drizzle/queries/lucia-auth.ts +0 -56
  100. package/dist/boilerplates/@batijs/drizzle/files/database/drizzle/schema/lucia-auth.ts +0 -41
  101. package/dist/boilerplates/@batijs/drizzle/types/database/drizzle/queries/lucia-auth.d.ts +0 -25
  102. package/dist/boilerplates/@batijs/drizzle/types/database/drizzle/schema/lucia-auth.d.ts +0 -190
  103. package/dist/boilerplates/@batijs/lucia-auth/files/$.env.js +0 -32
  104. package/dist/boilerplates/@batijs/lucia-auth/files/$README.md.js +0 -38
  105. package/dist/boilerplates/@batijs/lucia-auth/files/$package.json.js +0 -113
  106. package/dist/boilerplates/@batijs/lucia-auth/files/global.d.ts +0 -11
  107. package/dist/boilerplates/@batijs/lucia-auth/files/lib/lucia-auth.ts +0 -136
  108. package/dist/boilerplates/@batijs/lucia-auth/files/pages/login/+guard.ts +0 -11
  109. package/dist/boilerplates/@batijs/lucia-auth/files/pages/login/style.css +0 -94
  110. package/dist/boilerplates/@batijs/lucia-auth/files/server/lucia-auth-handlers.ts +0 -401
  111. package/dist/boilerplates/@batijs/lucia-auth/types/lib/lucia-auth.d.ts +0 -63
  112. package/dist/boilerplates/@batijs/lucia-auth/types/pages/login/+guard.d.ts +0 -3
  113. package/dist/boilerplates/@batijs/lucia-auth/types/server/lucia-auth-handlers.d.ts +0 -65
  114. package/dist/boilerplates/@batijs/react-lucia-auth/files/pages/login/+Page.tsx +0 -97
  115. package/dist/boilerplates/@batijs/react-lucia-auth/types/pages/login/+Page.d.ts +0 -2
  116. package/dist/boilerplates/@batijs/solid-lucia-auth/files/pages/login/+Page.tsx +0 -97
  117. package/dist/boilerplates/@batijs/solid-lucia-auth/types/pages/login/+Page.d.ts +0 -2
  118. package/dist/boilerplates/@batijs/sqlite/files/database/sqlite/queries/lucia-auth.ts +0 -27
  119. package/dist/boilerplates/@batijs/sqlite/files/database/sqlite/schema/lucia-auth.ts +0 -32
  120. package/dist/boilerplates/@batijs/sqlite/types/database/sqlite/queries/lucia-auth.d.ts +0 -5
  121. package/dist/boilerplates/@batijs/sqlite/types/database/sqlite/schema/lucia-auth.d.ts +0 -1
  122. package/dist/boilerplates/@batijs/vue-lucia-auth/files/pages/login/+Page.vue +0 -88
@@ -1,65 +0,0 @@
1
- import type { Session, User } from "lucia";
2
- import { type Get, type UniversalMiddleware } from "@universal-middleware/core";
3
- /**
4
- * Add lucia database to the context
5
- *
6
- * @link {@see https://universal-middleware.dev/examples/context-middleware}
7
- */
8
- export declare const luciaDbMiddleware: Get<[], UniversalMiddleware>;
9
- /**
10
- * CSRF protection middleware
11
- *
12
- * @link {@see https://lucia-auth.com/guides/validate-session-cookies/}
13
- */
14
- export declare const luciaCsrfMiddleware: () => (request: Request) => Promise<Response | undefined>;
15
- /**
16
- * Validate session cookies middleware and set context
17
- *
18
- * @link {@see https://lucia-auth.com/guides/validate-session-cookies/}
19
- */
20
- export declare const luciaAuthContextMiddleware: Get<[], UniversalMiddleware>;
21
- /**
22
- * Set Set-Cookie headers if in context
23
- */
24
- export declare const luciaAuthCookieMiddleware: () => (_request: Request, context: Universal.Context & {
25
- session?: Session | null;
26
- user?: User | null;
27
- sessionId?: string | null;
28
- }) => (response: Response) => Response;
29
- /**
30
- * Register user handler
31
- *
32
- * @link {@see https://lucia-auth.com/guides/email-and-password/basics#register-user}
33
- */
34
- export declare const luciaAuthSignupHandler: () => (request: Request, context: Universal.Context, _runtime: import("@universal-middleware/core").RuntimeAdapter) => Promise<Response>;
35
- /**
36
- * Sign in user handler
37
- *
38
- * @link {@see https://lucia-auth.com/guides/email-and-password/basics#sign-in-user}
39
- */
40
- export declare const luciaAuthLoginHandler: () => (request: Request, context: Universal.Context, _runtime: import("@universal-middleware/core").RuntimeAdapter) => Promise<Response>;
41
- /**
42
- * Log out user handler
43
- */
44
- export declare const luciaAuthLogoutHandler: () => (_request: Request, context: Universal.Context & {
45
- session?: Session | null;
46
- }) => Promise<Response>;
47
- /**
48
- * Github OAuth authorization handler
49
- *
50
- * @link {@see https://lucia-auth.com/guides/oauth/basics#creating-authorization-url}
51
- */
52
- export declare const luciaGithubLoginHandler: () => () => Promise<Response>;
53
- /**
54
- * Github OAuth validate callback handler
55
- *
56
- * @link {@see https://lucia-auth.com/guides/oauth/basics#validate-callback}
57
- */
58
- export declare const luciaGithubCallbackHandler: () => (request: Request, context: Universal.Context, _runtime: import("@universal-middleware/core").RuntimeAdapter) => Promise<Response>;
59
- export declare function validateInput(username: string | null, password: string | null): {
60
- error: {
61
- username: string | null;
62
- password: string | null;
63
- };
64
- success: boolean;
65
- };
@@ -1,97 +0,0 @@
1
- import "./style.css";
2
- import { 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
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
- const result: Record<string, any> = 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
-
43
- return (
44
- <div className="form">
45
- <div className="form-content">
46
- <header>Login / Sign Up</header>
47
- <form>
48
- <div className="field">
49
- <input
50
- id="username"
51
- type="text"
52
- name="username"
53
- value={formData.username}
54
- onChange={handleOnChange}
55
- placeholder="Username"
56
- autoComplete="username"
57
- />
58
- </div>
59
- {error.username && <span className="field-error">{error.username}</span>}
60
-
61
- <div className="field">
62
- <input
63
- id="password"
64
- type="password"
65
- name="password"
66
- value={formData.password}
67
- onChange={handleOnChange}
68
- placeholder="Password"
69
- />
70
- </div>
71
- {error.password && <span className="field-error">{error.password}</span>}
72
- {error.invalid && <span className="field-error">{error.invalid}</span>}
73
-
74
- <div className="field button-group">
75
- <button type="button" className="button-field signup-button" onClick={(e) => handleOnSubmit(e, "signup")}>
76
- Sign Up
77
- </button>
78
- <button type="submit" className="button-field login-button" onClick={(e) => handleOnSubmit(e, "login")}>
79
- Login
80
- </button>
81
- </div>
82
- </form>
83
- </div>
84
-
85
- <div className="media-options">
86
- <a href="/api/login/github" className="field github">
87
- <img
88
- src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCA0OTYgNTEyJz48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNi4wIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjQgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZD0nTTE2NS45IDM5Ny40YzAgMi0yLjMgMy42LTUuMiAzLjYtMy4zIC4zLTUuNi0xLjMtNS42LTMuNiAwLTIgMi4zLTMuNiA1LjItMy42IDMtLjMgNS42IDEuMyA1LjYgMy42em0tMzEuMS00LjVjLS43IDIgMS4zIDQuMyA0LjMgNC45IDIuNiAxIDUuNiAwIDYuMi0ycy0xLjMtNC4zLTQuMy01LjJjLTIuNi0uNy01LjUgLjMtNi4yIDIuM3ptNDQuMi0xLjdjLTIuOSAuNy00LjkgMi42LTQuNiA0LjkgLjMgMiAyLjkgMy4zIDUuOSAyLjYgMi45LS43IDQuOS0yLjYgNC42LTQuNi0uMy0xLjktMy0zLjItNS45LTIuOXpNMjQ0LjggOEMxMDYuMSA4IDAgMTEzLjMgMCAyNTJjMCAxMTAuOSA2OS44IDIwNS44IDE2OS41IDIzOS4yIDEyLjggMi4zIDE3LjMtNS42IDE3LjMtMTIuMSAwLTYuMi0uMy00MC40LS4zLTYxLjQgMCAwLTcwIDE1LTg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xMS40LTE0LjdjLTEuNiAxLTEuNiAzLjYgMCA1LjkgMS42IDIuMyA0LjMgMy4zIDUuNiAyLjMgMS42LTEuMyAxLjYtMy45IDAtNi4yLTEuNC0yLjMtNC0zLjMtNS42LTJ6Jy8+PC9zdmc+"
89
- className="github-icon"
90
- alt=""
91
- />
92
- <span>Login with Github</span>
93
- </a>
94
- </div>
95
- </div>
96
- );
97
- }
@@ -1,2 +0,0 @@
1
- import "./style.css";
2
- export default function Page(): import("react/jsx-runtime").JSX.Element;
@@ -1,97 +0,0 @@
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
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
- const result: Record<string, any> = await response.json();
33
- if ("error" in result) {
34
- console.error("A validation error has occurred :", result.error);
35
- setError(result.error);
36
- } else {
37
- await navigate("/");
38
- }
39
- } catch (err) {
40
- console.error("An unknown error has occurred :", err);
41
- }
42
- };
43
- return (
44
- <div class="form">
45
- <div class="form-content">
46
- <header>Login / Sign Up</header>
47
- <form>
48
- <div class="field">
49
- <input
50
- id="username"
51
- type="text"
52
- name="username"
53
- value={formData().username}
54
- onChange={handleOnChange}
55
- placeholder="Username"
56
- autocomplete="username"
57
- />
58
- </div>
59
- {error().username && <span class="field-error">{error().username}</span>}
60
-
61
- <div class="field">
62
- <input
63
- id="password"
64
- type="password"
65
- name="password"
66
- value={formData().password}
67
- onChange={handleOnChange}
68
- placeholder="Password"
69
- />
70
- </div>
71
- {error().password && <span class="field-error">{error().password}</span>}
72
- {error().invalid && <span class="field-error">{error().invalid}</span>}
73
-
74
- <div class="field button-group">
75
- <button type="button" class="button-field signup-button" onClick={(e) => handleOnSubmit(e, "signup")}>
76
- Sign Up
77
- </button>
78
- <button type="submit" class="button-field login-button" onClick={(e) => handleOnSubmit(e, "login")}>
79
- Login
80
- </button>
81
- </div>
82
- </form>
83
- </div>
84
-
85
- <div class="media-options">
86
- <a href="/api/login/github" class="field github">
87
- <img
88
- src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCA0OTYgNTEyJz48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNi4wIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjQgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZD0nTTE2NS45IDM5Ny40YzAgMi0yLjMgMy42LTUuMiAzLjYtMy4zIC4zLTUuNi0xLjMtNS42LTMuNiAwLTIgMi4zLTMuNiA1LjItMy42IDMtLjMgNS42IDEuMyA1LjYgMy42em0tMzEuMS00LjVjLS43IDIgMS4zIDQuMyA0LjMgNC45IDIuNiAxIDUuNiAwIDYuMi0ycy0xLjMtNC4zLTQuMy01LjJjLTIuNi0uNy01LjUgLjMtNi4yIDIuM3ptNDQuMi0xLjdjLTIuOSAuNy00LjkgMi42LTQuNiA0LjkgLjMgMiAyLjkgMy4zIDUuOSAyLjYgMi45LS43IDQuOS0yLjYgNC42LTQuNi0uMy0xLjktMy0zLjItNS45LTIuOXpNM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i0uNi0zLjYtLjMtNC4zIC43em0zMi40IDM1LjZjLTEuNiAxLjMtMSA0LjMgMS4zIDYuMiAyLjMgMi4zIDUuMiAyLjYgNi41IDEgMS4zLTEuMyAuNy00LjMtMS4zLTYuMi0yLjItMi4zLTUuMi0yLjYtNi41LTF6bS0xMS40LTE0LjdjLTEuNiAxLTEuNiAzLjYgMCA1LjkgMS42IDIuMyA0LjMgMy4zIDUuNiAyLjMgMS42LTEuMyAxLjYtMy45IDAtNi4yLTEuNC0yLjMtNC0zLjMtNS42LTJ6Jy8+PC9zdmc+"
89
- class="github-icon"
90
- alt=""
91
- />
92
- <span>Login with Github</span>
93
- </a>
94
- </div>
95
- </div>
96
- );
97
- }
@@ -1,2 +0,0 @@
1
- import "./style.css";
2
- export declare function Page(): import("solid-js").JSX.Element;
@@ -1,27 +0,0 @@
1
- /*# BATI include-if-imported #*/
2
- import type { Database, Transaction } from "better-sqlite3";
3
-
4
- export function getExistingUser<T>(db: Database, username: string) {
5
- return db.prepare<[string], T>("SELECT * FROM users WHERE username = ?").get(username);
6
- }
7
-
8
- export function getExistingAccount<T>(db: Database, providerId: string, providerUserId: number) {
9
- return db
10
- .prepare<[string, number], T>("SELECT * FROM oauth_accounts WHERE provider_id = ? AND provider_user_id = ?")
11
- .get(providerId, providerUserId);
12
- }
13
-
14
- export function signupWithGithub(db: Database, userId: string, username: string, githubUserId: number): Transaction {
15
- return db.transaction(() => {
16
- db.prepare("INSERT INTO users (id, username) VALUES (?, ?)").run(userId, username);
17
- db.prepare("INSERT INTO oauth_accounts (provider_id, provider_user_id, user_id) VALUES (?, ?, ?)").run(
18
- "github",
19
- githubUserId,
20
- userId,
21
- );
22
- });
23
- }
24
-
25
- export function signupWithCredentials(db: Database, userId: string, username: string, passwordHash: string) {
26
- return db.prepare("INSERT INTO users (id, username, password) VALUES(?, ?, ?)").run(userId, username, passwordHash);
27
- }
@@ -1,32 +0,0 @@
1
- /*{ @if (it.BATI.has("lucia-auth")) }*/
2
- import "dotenv/config";
3
- import { db } from "../db";
4
-
5
- const client = db();
6
-
7
- /**
8
- * SQLite Schema
9
- *
10
- * @link {@see https://lucia-auth.com/database/sqlite#schema}
11
- */
12
- client.exec(`CREATE TABLE IF NOT EXISTS users (
13
- id TEXT NOT NULL PRIMARY KEY,
14
- username TEXT NOT NULL UNIQUE,
15
- password TEXT
16
- )`);
17
-
18
- client.exec(`CREATE TABLE IF NOT EXISTS oauth_accounts (
19
- provider_id TEXT NOT NULL,
20
- provider_user_id INTEGER NOT NULL,
21
- user_id TEXT NOT NULL,
22
- PRIMARY KEY (provider_id, provider_user_id),
23
- FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE cascade ON DELETE cascade
24
- )`);
25
-
26
- client.exec(`CREATE TABLE IF NOT EXISTS sessions (
27
- id TEXT NOT NULL PRIMARY KEY,
28
- expires_at INTEGER NOT NULL,
29
- user_id TEXT NOT NULL,
30
- FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE cascade ON DELETE cascade
31
- )`);
32
- /*{ /if }*/
@@ -1,5 +0,0 @@
1
- import type { Database, Transaction } from "better-sqlite3";
2
- export declare function getExistingUser<T>(db: Database, username: string): T | undefined;
3
- export declare function getExistingAccount<T>(db: Database, providerId: string, providerUserId: number): T | undefined;
4
- export declare function signupWithGithub(db: Database, userId: string, username: string, githubUserId: number): Transaction;
5
- export declare function signupWithCredentials(db: Database, userId: string, username: string, passwordHash: string): import("better-sqlite3").RunResult;
@@ -1,88 +0,0 @@
1
- <template>
2
- <div class="form">
3
- <div class="form-content">
4
- <header>Login / Sign Up</header>
5
- <form>
6
- <div class="field">
7
- <input
8
- id="username"
9
- v-model="formData.username"
10
- type="text"
11
- name="username"
12
- placeholder="Username"
13
- autocomplete="username"
14
- />
15
- </div>
16
- <span v-if="error.username" class="field-error">{{ error.username }}</span>
17
-
18
- <div class="field">
19
- <input id="password" v-model="formData.password" type="password" name="password" placeholder="Password" />
20
- </div>
21
- <span v-if="error.password" class="field-error">{{ error.password }}</span>
22
- <span v-if="error.invalid" class="field-error">{{ error.invalid }}</span>
23
-
24
- <div class="field button-group">
25
- <button type="button" class="button-field signup-button" @click.prevent="handleOnSubmit('signup')">
26
- Sign Up
27
- </button>
28
- <button type="submit" class="button-field login-button" @click.prevent="handleOnSubmit('login')">
29
- Login
30
- </button>
31
- </div>
32
- </form>
33
- </div>
34
-
35
- <div class="media-options">
36
- <a href="/api/login/github" class="field github">
37
- <img
38
- src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCA0OTYgNTEyJz48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNi4wIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjQgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZD0nTTE2NS45IDM5Ny40YzAgMi0yLjMgMy42LTUuMiAzLjYtMy4zIC4zLTUuNi0xLjMtNS42LTMuNiAwLTIgMi4zLTMuNiA1LjItMy42IDMtLjMgNS42IDEuMyA1LjYgMy42em0tMzEuMS00LjVjLS43IDIgMS4zIDQuMyA0LjMgNC45IDIuNiAxIDUuNiAwIDYuMi0ycy0xLjMtNC4zLTQuMy01LjJjLTIuNi0uNy01LjUgLjMtNi4yIDIuM3ptNDQuMi0xLjdjLTIuOSAuNy00LjkgMi42LTQuNiA0LjkgLjMgMiAyLjkgMy4zIDUuOSAyLjYgMi45LS43IDQuOS0yLjYgNC42LTQuNi0uMy0xLjktMy0zLjItNS45LTIuOXpNMjQ0LjggOEMxMDYuMSA4IDAgMTEzLjMgMCAyNTJjMCAxMTAuOSA2OS44IDIwNS44IDE2OS41IDIzOS4yIDEyLjggMi4zIDE3LjMtNS42IDE3LjMtMTIuMSAwLTYuMi0uMy00MC40LS4zLTY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UuMi0yLjYtNi41LTF6bS0xMS40LTE0LjdjLTEuNiAxLTEuNiAzLjYgMCA1LjkgMS42IDIuMyA0LjMgMy4zIDUuNiAyLjMgMS42LTEuMyAxLjYtMy45IDAtNi4yLTEuNC0yLjMtNC0zLjMtNS42LTJ6Jy8+PC9zdmc+"
39
- class="github-icon"
40
- alt=""
41
- />
42
- <span>Login with Github</span>
43
- </a>
44
- </div>
45
- </div>
46
- </template>
47
-
48
- <script lang="ts" setup>
49
- import "./style.css";
50
- import { navigate } from "vike/client/router";
51
- import { ref } from "vue";
52
-
53
- type ValidationError = {
54
- username: string | null;
55
- password: string | null;
56
- invalid?: string;
57
- };
58
-
59
- const formData = ref({
60
- username: "",
61
- password: "",
62
- });
63
-
64
- let error = ref<ValidationError>({
65
- username: null,
66
- password: null,
67
- });
68
-
69
- async function handleOnSubmit(action: "login" | "signup") {
70
- try {
71
- const response = await fetch(`/api/${action}`, {
72
- method: "POST",
73
- body: JSON.stringify(formData.value),
74
- headers: { "Content-Type": "application/json" },
75
- });
76
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
- const result: Record<string, any> = await response.json();
78
- if ("error" in result) {
79
- console.error("A validation error has occurred :", result.error);
80
- error.value = { ...result.error };
81
- } else {
82
- await navigate("/");
83
- }
84
- } catch (err) {
85
- console.error("An unknown error has occurred :", err);
86
- }
87
- }
88
- </script>