mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
Fixing linting issues.
This commit is contained in:
parent
e7d1df356e
commit
527906b451
14 changed files with 42 additions and 56 deletions
|
|
@ -39,11 +39,12 @@ export const authentication: Handle = async function ({ event, resolve }) {
|
||||||
...sessionCookie.attributes
|
...sessionCookie.attributes
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
console.log('session from hooks', JSON.stringify(session, null, 2));
|
||||||
if (!session) {
|
if (!session) {
|
||||||
const sessionCookie = lucia.createBlankSessionCookie();
|
const sessionCookie = lucia.createBlankSessionCookie();
|
||||||
console.log('blank sessionCookie', JSON.stringify(sessionCookie, null, 2));
|
console.log('blank sessionCookie', JSON.stringify(sessionCookie, null, 2));
|
||||||
event.cookies.set(sessionCookie.name, sessionCookie.value, {
|
event.cookies.set(sessionCookie.name, sessionCookie.value, {
|
||||||
path: ".",
|
path: '.',
|
||||||
...sessionCookie.attributes
|
...sessionCookie.attributes
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -57,4 +58,4 @@ export const handle: Handle = sequence(
|
||||||
// Sentry.sentryHandle(),
|
// Sentry.sentryHandle(),
|
||||||
authentication
|
authentication
|
||||||
);
|
);
|
||||||
// export const handleError = Sentry.handleErrorWithSentry();
|
// export const handleError = Sentry.handleErrorWithSentry();
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,11 @@
|
||||||
import * as Avatar from "$components/ui/avatar";
|
import * as Avatar from "$components/ui/avatar";
|
||||||
import { invalidateAll } from '$app/navigation';
|
import { invalidateAll } from '$app/navigation';
|
||||||
import Logo from '$components/logo.svelte';
|
import Logo from '$components/logo.svelte';
|
||||||
import type { Users } from '../../schema';
|
import type { Users } from "../../schema";
|
||||||
|
|
||||||
export let user: Users;
|
export let user: Users | null = null;
|
||||||
|
|
||||||
|
console.log('header user', user);
|
||||||
|
|
||||||
let avatar: string;
|
let avatar: string;
|
||||||
let loggedIn = false;
|
let loggedIn = false;
|
||||||
|
|
@ -30,7 +32,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- <TextSearch /> -->
|
<!-- <TextSearch /> -->
|
||||||
<nav>
|
<nav>
|
||||||
{#if loggedIn}
|
{#if user}
|
||||||
<a href="/collection" title="Go to your collection" data-sveltekit-preload-data>Collection</a>
|
<a href="/collection" title="Go to your collection" data-sveltekit-preload-data>Collection</a>
|
||||||
<a href="/wishlist" title="Go to your wishlist" data-sveltekit-preload-data>Wishlist</a>
|
<a href="/wishlist" title="Go to your wishlist" data-sveltekit-preload-data>Wishlist</a>
|
||||||
<DropdownMenu.Root>
|
<DropdownMenu.Root>
|
||||||
|
|
@ -95,8 +97,7 @@
|
||||||
</DropdownMenu.Group>
|
</DropdownMenu.Group>
|
||||||
</DropdownMenu.Content>
|
</DropdownMenu.Content>
|
||||||
</DropdownMenu.Root>
|
</DropdownMenu.Root>
|
||||||
{/if}
|
{:else}
|
||||||
{#if !loggedIn}
|
|
||||||
<a href="/login">
|
<a href="/login">
|
||||||
<span class="flex-auto">Login</span></a
|
<span class="flex-auto">Login</span></a
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
|
import { error } from '@sveltejs/kit';
|
||||||
|
import { eq } from 'drizzle-orm';
|
||||||
import kebabCase from 'just-kebab-case';
|
import kebabCase from 'just-kebab-case';
|
||||||
|
import { PUBLIC_SITE_URL } from '$env/static/public';
|
||||||
import db from '$lib/drizzle';
|
import db from '$lib/drizzle';
|
||||||
import { externalIds, type Mechanics, type Categories, categories, categoriesToExternalIds } from '../../../schema';
|
import { externalIds, type Mechanics, type Categories, categories, categoriesToExternalIds } from '../../../schema';
|
||||||
import { eq } from 'drizzle-orm';
|
|
||||||
import { error } from '@sveltejs/kit';
|
|
||||||
import { PUBLIC_SITE_URL } from '$env/static/public';
|
|
||||||
|
|
||||||
export async function createCategory(locals: App.Locals, category: Categories, externalId: string) {
|
export async function createCategory(locals: App.Locals, category: Categories, externalId: string) {
|
||||||
if (!category || !externalId || externalId === '') {
|
if (!category || !externalId || externalId === '') {
|
||||||
|
|
@ -44,7 +44,7 @@ export async function createCategory(locals: App.Locals, category: Categories, e
|
||||||
.insert(categories)
|
.insert(categories)
|
||||||
.values({
|
.values({
|
||||||
name: category.name,
|
name: category.name,
|
||||||
slug: kebabCase(category.name || category.slug || '')
|
slug: kebabCase(category.name ?? category.slug ?? '')
|
||||||
})
|
})
|
||||||
.returning();
|
.returning();
|
||||||
const dbExternalIds = await transaction
|
const dbExternalIds = await transaction
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<h1>At the admin page yo!</h1>
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
import { type Actions, fail, redirect } from "@sveltejs/kit";
|
import { type Actions, fail, redirect } from "@sveltejs/kit";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import db from "$lib/drizzle.js";
|
|
||||||
import { superValidate } from 'sveltekit-superforms/server';
|
|
||||||
import { games, wishlist_items, wishlists } from "../../../../../schema.js";
|
|
||||||
import { zod } from "sveltekit-superforms/adapters";
|
import { zod } from "sveltekit-superforms/adapters";
|
||||||
|
import { superValidate } from 'sveltekit-superforms/server';
|
||||||
|
import db from "$lib/drizzle.js";
|
||||||
|
import { modifyListGameSchema } from "$lib/validations/zod-schemas";
|
||||||
|
import { games, wishlist_items, wishlists } from "../../../../../schema.js";
|
||||||
|
|
||||||
export async function load({ params, locals }) {
|
export async function load({ params, locals }) {
|
||||||
const user = locals.user;
|
const user = locals.user;
|
||||||
|
|
@ -14,31 +15,16 @@ export async function load({ params, locals }) {
|
||||||
try {
|
try {
|
||||||
const wishlist = await db.select({
|
const wishlist = await db.select({
|
||||||
wishlistId: wishlists.id,
|
wishlistId: wishlists.id,
|
||||||
wishlistName: wishlists.name,
|
|
||||||
wishlistItems: {
|
wishlistItems: {
|
||||||
id: wishlist_items.id,
|
id: wishlist_items.id,
|
||||||
gameId: wishlist_items.game_id,
|
gameId: wishlist_items.game_id,
|
||||||
gameName: games.name,
|
gameName: games.name,
|
||||||
gameThumbUrl: games.thumb_url
|
gameThumbUrl: games.thumb_url
|
||||||
},
|
},
|
||||||
}).from(wishlists).leftJoin(wishlist_items, eq(wishlists.id, wishlist_items.wishlist_id)).leftJoin(games, eq(games.id, wishlist_items.game_id)).where(eq(wishlists.id, params.id));
|
}).from(wishlists)
|
||||||
// let wishlist = await db.query.wishlists.findFirst({
|
.leftJoin(wishlist_items, eq(wishlists.id, wishlist_items.wishlist_id))
|
||||||
// where: and(eq(wishlists.id, params.id), eq(wishlists.user_id, user.id)),
|
.leftJoin(games, eq(games.id, wishlist_items.game_id))
|
||||||
// with: {
|
.where(eq(wishlists.id, params.id));
|
||||||
// : {
|
|
||||||
// include: {
|
|
||||||
// game: {
|
|
||||||
// select: {
|
|
||||||
// id: true,
|
|
||||||
// name: true,
|
|
||||||
// thumb_url: true
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
wishlist
|
wishlist
|
||||||
};
|
};
|
||||||
|
|
@ -69,11 +55,6 @@ export const actions: Actions = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!game) {
|
if (!game) {
|
||||||
// game = await prisma.game.create({
|
|
||||||
// data: {
|
|
||||||
// name: form.name
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
return fail(400, {
|
return fail(400, {
|
||||||
message: 'Game not found'
|
message: 'Game not found'
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ export const actions: Actions = {
|
||||||
where: eq(users.id, user.id)
|
where: eq(users.id, user.id)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!dbUser || !dbUser.hashed_password) {
|
if (!dbUser?.hashed_password) {
|
||||||
form.data.password = '';
|
form.data.password = '';
|
||||||
form.data.confirm_password = '';
|
form.data.confirm_password = '';
|
||||||
form.data.current_password = '';
|
form.data.current_password = '';
|
||||||
|
|
@ -81,8 +81,8 @@ export const actions: Actions = {
|
||||||
await db.update(users)
|
await db.update(users)
|
||||||
.set({ hashed_password: hashedPassword })
|
.set({ hashed_password: hashedPassword })
|
||||||
.where(eq(users.id, user.id));
|
.where(eq(users.id, user.id));
|
||||||
const session = await lucia.createSession(user.id, {
|
await lucia.createSession(user.id, {
|
||||||
country: event.locals.session?.ip,
|
country: event.locals.session?.ipCountry ?? 'unknown',
|
||||||
});
|
});
|
||||||
sessionCookie = lucia.createBlankSessionCookie();
|
sessionCookie = lucia.createBlankSessionCookie();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -25,14 +25,14 @@ export const load: PageServerLoad = async (event) => {
|
||||||
|
|
||||||
const profileForm = await superValidate(zod(profileSchema), {
|
const profileForm = await superValidate(zod(profileSchema), {
|
||||||
defaults: {
|
defaults: {
|
||||||
firstName: dbUser?.first_name || '',
|
firstName: dbUser?.first_name ?? '',
|
||||||
lastName: dbUser?.last_name || '',
|
lastName: dbUser?.last_name ?? '',
|
||||||
username: dbUser?.username || '',
|
username: dbUser?.username ?? '',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const emailForm = await superValidate(zod(changeEmailSchema), {
|
const emailForm = await superValidate(zod(changeEmailSchema), {
|
||||||
defaults: {
|
defaults: {
|
||||||
email: dbUser?.email || '',
|
email: dbUser?.email ?? '',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -66,7 +66,6 @@ export const actions: Actions = {
|
||||||
console.log('updating profile');
|
console.log('updating profile');
|
||||||
|
|
||||||
const user = event.locals.user;
|
const user = event.locals.user;
|
||||||
|
|
||||||
const newUsername = form.data.username;
|
const newUsername = form.data.username;
|
||||||
const existingUser = await db.query
|
const existingUser = await db.query
|
||||||
.users
|
.users
|
||||||
|
|
@ -102,7 +101,7 @@ export const actions: Actions = {
|
||||||
const form = await superValidate(event, zod(changeEmailSchema));
|
const form = await superValidate(event, zod(changeEmailSchema));
|
||||||
|
|
||||||
const newEmail = form.data?.email;
|
const newEmail = form.data?.email;
|
||||||
if (!form.valid || !newEmail || (newEmail !== '' && changeEmailIfNotEmpty.safeParse(form.data).success === false)) {
|
if (!form.valid || !newEmail || (newEmail !== '' && !changeEmailIfNotEmpty.safeParse(form.data).success)) {
|
||||||
return fail(400, {
|
return fail(400, {
|
||||||
form
|
form
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { loadFlash } from 'sveltekit-flash-message/server';
|
||||||
import type { LayoutServerLoad } from '../$types';
|
import type { LayoutServerLoad } from '../$types';
|
||||||
|
|
||||||
export const load: LayoutServerLoad = loadFlash(async ({ url, locals }) => {
|
export const load: LayoutServerLoad = loadFlash(async ({ url, locals }) => {
|
||||||
|
console.log('user from app', locals.user);
|
||||||
return {
|
return {
|
||||||
url: url.pathname,
|
url: url.pathname,
|
||||||
user: locals.user
|
user: locals.user
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
import Footer from '$components/Footer.svelte';
|
import Footer from '$components/Footer.svelte';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
|
console.log('layout data user', data.user);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Header user={data.user} />
|
<Header user={data.user} />
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,6 @@ import { notSignedInMessage } from '$lib/flashMessages';
|
||||||
|
|
||||||
export async function load(event) {
|
export async function load(event) {
|
||||||
const { url, locals } = event;
|
const { url, locals } = event;
|
||||||
if (locals.user) {
|
|
||||||
redirect(302, '/', notSignedInMessage, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: url.pathname,
|
url: url.pathname,
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,9 @@ export const actions: Actions = {
|
||||||
ip_country: locals.country,
|
ip_country: locals.country,
|
||||||
ip_address: locals.ip
|
ip_address: locals.ip
|
||||||
});
|
});
|
||||||
|
console.log('logging in session', session);
|
||||||
sessionCookie = lucia.createSessionCookie(session.id);
|
sessionCookie = lucia.createSessionCookie(session.id);
|
||||||
|
console.log('logging in session cookie', sessionCookie);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// TODO: need to return error message to the client
|
// TODO: need to return error message to the client
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|
@ -93,6 +95,6 @@ export const actions: Actions = {
|
||||||
form.data.username = '';
|
form.data.username = '';
|
||||||
form.data.password = '';
|
form.data.password = '';
|
||||||
const message = { type: 'success', message: 'Signed In!' } as const;
|
const message = { type: 'success', message: 'Signed In!' } as const;
|
||||||
redirect('/', message, event);
|
redirect(302, '/', message, event);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { fail } from '@sveltejs/kit';
|
import { fail } from '@sveltejs/kit';
|
||||||
import { lucia } from '$lib/server/auth';
|
|
||||||
import type { Actions } from "./$types";
|
|
||||||
import { redirect } from 'sveltekit-flash-message/server';
|
import { redirect } from 'sveltekit-flash-message/server';
|
||||||
|
import { lucia } from '$lib/server/auth';
|
||||||
import { notSignedInMessage } from '$lib/flashMessages';
|
import { notSignedInMessage } from '$lib/flashMessages';
|
||||||
|
import type { Actions } from "./$types";
|
||||||
|
|
||||||
export const actions: Actions = {
|
export const actions: Actions = {
|
||||||
default: async (event) => {
|
default: async (event) => {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ const signUpDefaults = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const load: PageServerLoad = async (event) => {
|
export const load: PageServerLoad = async (event) => {
|
||||||
redirect(302, '/waitlist', { type: 'error', message: 'Sign-up not yet available. Please add your email to the waitlist!' }, event);
|
// redirect(302, '/waitlist', { type: 'error', message: 'Sign-up not yet available. Please add your email to the waitlist!' }, event);
|
||||||
|
|
||||||
if (event.locals.user) {
|
if (event.locals.user) {
|
||||||
const message = { type: 'success', message: 'You are already signed in' } as const;
|
const message = { type: 'success', message: 'You are already signed in' } as const;
|
||||||
|
|
@ -39,7 +39,7 @@ export const load: PageServerLoad = async (event) => {
|
||||||
|
|
||||||
export const actions: Actions = {
|
export const actions: Actions = {
|
||||||
default: async (event) => {
|
default: async (event) => {
|
||||||
fail(401, { message: 'Sign-up not yet available. Please add your email to the waitlist!' });
|
// fail(401, { message: 'Sign-up not yet available. Please add your email to the waitlist!' });
|
||||||
const form = await superValidate(event, zod(signUpSchema));
|
const form = await superValidate(event, zod(signUpSchema));
|
||||||
if (!form.valid) {
|
if (!form.valid) {
|
||||||
form.data.password = '';
|
form.data.password = '';
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
"checkJs": true,
|
"checkJs": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"useUnknownInCatchVariables": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue