Compare commits

...

2 Commits

Author SHA1 Message Date
Balázs Orbán
57b176840e chore(release): bump package version(s) [skip ci] 2022-12-14 09:49:43 +01:00
Thang Vu
6298d955df fix(frameworks): run check before building for @auth/sveltekit (#6044)
* fix(frameworks): run check before building for @auth/sveltekit

* run format
2022-12-14 15:44:08 +07:00
3 changed files with 11 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@auth/sveltekit", "name": "@auth/sveltekit",
"version": "0.1.2", "version": "0.1.3",
"description": "Authentication for SvelteKit.", "description": "Authentication for SvelteKit.",
"homepage": "https://sveltekit.authjs.dev", "homepage": "https://sveltekit.authjs.dev",
"repository": "https://github.com/nextauthjs/next-auth.git", "repository": "https://github.com/nextauthjs/next-auth.git",
@@ -15,7 +15,7 @@
"scripts": { "scripts": {
"dev": "svelte-package -w", "dev": "svelte-package -w",
"clean": "rm -rf client.* index.* package", "clean": "rm -rf client.* index.* package",
"build": "pnpm clean && svelte-package && node ./scripts/postbuild.js && rm -rf package", "build": "pnpm clean && pnpm check && svelte-package && node ./scripts/postbuild.js && rm -rf package",
"preview": "vite preview", "preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",

View File

@@ -2,6 +2,7 @@ import { AUTH_SECRET, AUTH_TRUST_HOST, VERCEL } from "$env/static/private"
import { dev } from "$app/environment" import { dev } from "$app/environment"
import { AuthHandler, type AuthOptions, type AuthAction } from "@auth/core" import { AuthHandler, type AuthOptions, type AuthAction } from "@auth/core"
import type { Handle } from "@sveltejs/kit"
export async function getServerSession( export async function getServerSession(
req: Request, req: Request,
@@ -48,11 +49,14 @@ const actions: AuthAction[] = [
] ]
/** The main entry point to @auth/sveltekit */ /** The main entry point to @auth/sveltekit */
function SvelteKitAuth({ prefix = "/auth", ...options }: SvelteKitAuthOptions) { function SvelteKitAuth({
prefix = "/auth",
...options
}: SvelteKitAuthOptions): Handle {
options.secret ??= AUTH_SECRET options.secret ??= AUTH_SECRET
options.trustHost ??= !!(AUTH_TRUST_HOST ?? VERCEL ?? dev) options.trustHost ??= !!(AUTH_TRUST_HOST ?? VERCEL ?? dev)
return (({ event, resolve }) => { return ({ event, resolve }) => {
const [action] = event.url.pathname.slice(prefix.length + 1).split("/") const [action] = event.url.pathname.slice(prefix.length + 1).split("/")
const isAuth = actions.includes(action as AuthAction) const isAuth = actions.includes(action as AuthAction)
@@ -65,7 +69,7 @@ function SvelteKitAuth({ prefix = "/auth", ...options }: SvelteKitAuthOptions) {
} }
return AuthHandler(event.request, options) return AuthHandler(event.request, options)
}) satisfies Handle }
} }
export default SvelteKitAuth export default SvelteKitAuth

View File

@@ -1,5 +1,5 @@
{ {
// "extends": "./.svelte-kit/tsconfig.json", "extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": { "compilerOptions": {
"allowJs": true, "allowJs": true,
"checkJs": true, "checkJs": true,
@@ -8,8 +8,7 @@
"resolveJsonModule": true, "resolveJsonModule": true,
"skipLibCheck": true, "skipLibCheck": true,
"sourceMap": true, "sourceMap": true,
"strict": true, "strict": true
"moduleResolution": "node"
}, },
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
// //