-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: actual example of solid authjs (#1658)
- Loading branch information
Showing
22 changed files
with
1,462 additions
and
572 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
DISCORD_CLIENT_ID= | ||
DISCORD_CLIENT_SECRET= | ||
AUTH_SECRET=d40e96a10287cfcf90c6b91679f512ee | ||
AUTH_TRUST_HOST=true | ||
DISCORD_ID= | ||
DISCORD_SECRET= | ||
AUTH_SECRET=b198e07a64406260b98f06e21c457b84 | ||
AUTH_TRUST_HOST=true | ||
AUTH_URL=http://localhost:3000 | ||
VITE_AUTH_PATH=/api/auth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": "./tsconfig.json" | ||
}, | ||
"plugins": ["@typescript-eslint"], | ||
"extends": [ | ||
"plugin:solid/typescript", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"rules": { | ||
"@typescript-eslint/consistent-type-imports": "warn" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
dist | ||
.solid | ||
.output | ||
.vercel | ||
.netlify | ||
netlify | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# IDEs and editors | ||
/.idea | ||
.project | ||
.classpath | ||
*.launch | ||
.settings/ | ||
|
||
# Temp | ||
gitignore | ||
|
||
# System Files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"files.associations": { | ||
"*.css": "tailwindcss" | ||
}, | ||
"editor.quickSuggestions": { | ||
"strings": true | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { defineConfig } from "@solidjs/start/config"; | ||
|
||
export default defineConfig({}); | ||
export default defineConfig({ | ||
ssr: true, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,3 @@ | ||
body { | ||
font-family: Gordita, Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; | ||
} | ||
|
||
main { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
a { | ||
margin-right: 1rem; | ||
} | ||
|
||
main { | ||
text-align: center; | ||
padding: 1em; | ||
gap: 0.5rem; | ||
} | ||
|
||
main img { | ||
height: 3rem; | ||
width: 3rem; | ||
border-radius: 50%; | ||
} | ||
|
||
h1 { | ||
color: #335d92; | ||
text-transform: uppercase; | ||
font-size: 4rem; | ||
font-weight: 100; | ||
line-height: 1.1; | ||
margin: 4rem auto; | ||
max-width: 14rem; | ||
} | ||
|
||
main button { | ||
width: 3.5rem; | ||
padding: 0.5rem; | ||
width: 12rem; | ||
border: none; | ||
border-radius: 0.25rem; | ||
background: #335d92; | ||
color: #fff; | ||
font-size: 1.5rem; | ||
cursor: pointer; | ||
} | ||
|
||
main span { | ||
font-size: 1rem; | ||
font-weight: bold; | ||
} | ||
|
||
p { | ||
max-width: 14rem; | ||
margin: 2rem auto; | ||
line-height: 1.35; | ||
} | ||
|
||
@media (min-width: 480px) { | ||
h1 { | ||
max-width: none; | ||
} | ||
|
||
p { | ||
max-width: none; | ||
} | ||
} | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { mount, StartClient } from "@solidjs/start/client"; | ||
|
||
mount(() => <StartClient />, document.getElementById("app")); | ||
mount(() => <StartClient />, document.getElementById("app")!); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { ZodFormattedError } from "zod"; | ||
import { clientScheme } from "./schema"; | ||
|
||
export const formatErrors = ( | ||
errors: ZodFormattedError<Map<string, string>, string> | ||
) => | ||
Object.entries(errors) | ||
.map(([name, value]) => { | ||
if (value && "_errors" in value) | ||
return `${name}: ${value._errors.join(", ")}\n`; | ||
}) | ||
.filter(Boolean); | ||
|
||
const env = clientScheme.safeParse(import.meta.env); | ||
|
||
if (env.success === false) { | ||
console.error( | ||
"❌ Invalid environment variables:\n", | ||
...formatErrors(env.error.format()) | ||
); | ||
throw new Error("Invalid environment variables"); | ||
} | ||
|
||
export const clientEnv = env.data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { z } from "zod"; | ||
|
||
export const serverScheme = z.object({ | ||
NODE_ENV: z.enum(['development', 'production', 'test']).default('development'), | ||
DISCORD_ID: z.string(), | ||
DISCORD_SECRET: z.string(), | ||
AUTH_SECRET: z.string(), | ||
AUTH_TRUST_HOST: z.string().optional(), | ||
AUTH_URL: z.string().optional(), | ||
}); | ||
|
||
export const clientScheme = z.object({ | ||
MODE: z.enum(['development', 'production', 'test']).default('development'), | ||
VITE_AUTH_PATH: z.string().optional(), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { serverScheme } from "./schema"; | ||
import type { ZodFormattedError } from "zod"; | ||
|
||
export const formatErrors = ( | ||
errors: ZodFormattedError<Map<string, string>, string> | ||
) => | ||
Object.entries(errors) | ||
.map(([name, value]) => { | ||
if (value && "_errors" in value) | ||
return `${name}: ${value._errors.join(", ")}\n`; | ||
}) | ||
.filter(Boolean); | ||
|
||
const env = serverScheme.safeParse(process.env); | ||
|
||
if (env.success === false) { | ||
console.error( | ||
"❌ Invalid environment variables:\n", | ||
...formatErrors(env.error.format()) | ||
); | ||
throw new Error("Invalid environment variables"); | ||
} | ||
|
||
export const serverEnv = env.data; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.