mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
Fixing prisma issues by removing from locals and just using as singleton import. Upgrading libraries.
This commit is contained in:
parent
7d334f9cb7
commit
4e300a72a1
24 changed files with 1636 additions and 1812 deletions
38
package.json
38
package.json
|
|
@ -29,43 +29,43 @@
|
||||||
"@melt-ui/pp": "^0.1.2",
|
"@melt-ui/pp": "^0.1.2",
|
||||||
"@playwright/test": "^1.37.0",
|
"@playwright/test": "^1.37.0",
|
||||||
"@resvg/resvg-js": "^2.4.1",
|
"@resvg/resvg-js": "^2.4.1",
|
||||||
"@sveltejs/adapter-auto": "^1.0.3",
|
"@sveltejs/adapter-auto": "^2.1.1",
|
||||||
"@sveltejs/adapter-vercel": "^1.0.6",
|
"@sveltejs/adapter-vercel": "^3.0.3",
|
||||||
"@sveltejs/kit": "^1.25.2",
|
"@sveltejs/kit": "^1.27.2",
|
||||||
"@types/cookie": "^0.5.1",
|
"@types/cookie": "^0.5.1",
|
||||||
"@types/node": "^18.17.5",
|
"@types/node": "^18.17.5",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
"@typescript-eslint/eslint-plugin": "^6.7.5",
|
||||||
"@typescript-eslint/parser": "^5.62.0",
|
"@typescript-eslint/parser": "^6.7.5",
|
||||||
"autoprefixer": "^10.4.15",
|
"autoprefixer": "^10.4.15",
|
||||||
"eslint": "^8.47.0",
|
"eslint": "^8.47.0",
|
||||||
"eslint-config-prettier": "^8.10.0",
|
"eslint-config-prettier": "^9.0.0",
|
||||||
"eslint-plugin-svelte": "^2.32.4",
|
"eslint-plugin-svelte": "^2.32.4",
|
||||||
"just-clone": "^6.2.0",
|
"just-clone": "^6.2.0",
|
||||||
"just-debounce-it": "^3.2.0",
|
"just-debounce-it": "^3.2.0",
|
||||||
"postcss": "^8.4.30",
|
"postcss": "^8.4.31",
|
||||||
"postcss-import": "^15.1.0",
|
"postcss-import": "^15.1.0",
|
||||||
"postcss-load-config": "^4.0.1",
|
"postcss-load-config": "^4.0.1",
|
||||||
"postcss-preset-env": "^8.5.1",
|
"postcss-preset-env": "^9.3.0",
|
||||||
"prettier": "^2.8.8",
|
"prettier": "^3.0.3",
|
||||||
"prettier-plugin-svelte": "^2.10.1",
|
"prettier-plugin-svelte": "^3.0.3",
|
||||||
"prisma": "^5.4.2",
|
"prisma": "^5.3.1",
|
||||||
"sass": "^1.65.1",
|
"sass": "^1.65.1",
|
||||||
"satori": "^0.10.4",
|
"satori": "^0.10.4",
|
||||||
"satori-html": "^0.3.2",
|
"satori-html": "^0.3.2",
|
||||||
"svelte": "^4.2.1",
|
"svelte": "^4.2.2",
|
||||||
"svelte-check": "^3.5.0",
|
"svelte-check": "^3.5.2",
|
||||||
"svelte-meta-tags": "^3.0.4",
|
"svelte-meta-tags": "^3.0.4",
|
||||||
"svelte-preprocess": "^5.0.4",
|
"svelte-preprocess": "^5.0.4",
|
||||||
"svelte-sequential-preprocessor": "^2.0.1",
|
"svelte-sequential-preprocessor": "^2.0.1",
|
||||||
"sveltekit-flash-message": "^2.2.1",
|
"sveltekit-flash-message": "^2.2.1",
|
||||||
"sveltekit-superforms": "^1.7.2",
|
"sveltekit-superforms": "^1.9.0",
|
||||||
"tailwindcss": "^3.3.3",
|
"tailwindcss": "^3.3.3",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"tslib": "^2.6.1",
|
"tslib": "^2.6.1",
|
||||||
"typescript": "^5.1.6",
|
"typescript": "^5.1.6",
|
||||||
"vite": "^4.4.9",
|
"vite": "^4.4.9",
|
||||||
"vitest": "^0.25.3",
|
"vitest": "^0.34.6",
|
||||||
"zod": "^3.22.2"
|
"zod": "^3.22.4"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|
@ -82,8 +82,8 @@
|
||||||
"@lukeed/uuid": "^2.0.1",
|
"@lukeed/uuid": "^2.0.1",
|
||||||
"@melt-ui/svelte": "^0.50.1",
|
"@melt-ui/svelte": "^0.50.1",
|
||||||
"@paralleldrive/cuid2": "^2.2.2",
|
"@paralleldrive/cuid2": "^2.2.2",
|
||||||
"@prisma/client": "^5.4.2",
|
"@prisma/client": "^5.3.1",
|
||||||
"@sentry/sveltekit": "^7.74.0",
|
"@sentry/sveltekit": "^7.77.0",
|
||||||
"@types/feather-icons": "^4.29.1",
|
"@types/feather-icons": "^4.29.1",
|
||||||
"@vercel/og": "^0.5.13",
|
"@vercel/og": "^0.5.13",
|
||||||
"bits-ui": "^0.0.27",
|
"bits-ui": "^0.0.27",
|
||||||
|
|
@ -97,7 +97,7 @@
|
||||||
"iconify-icon": "^1.0.8",
|
"iconify-icon": "^1.0.8",
|
||||||
"just-kebab-case": "^4.2.0",
|
"just-kebab-case": "^4.2.0",
|
||||||
"loader": "^2.1.1",
|
"loader": "^2.1.1",
|
||||||
"lucia": "^2.7.1",
|
"lucia": "^2.7.2",
|
||||||
"lucide-svelte": "^0.256.1",
|
"lucide-svelte": "^0.256.1",
|
||||||
"open-props": "^1.5.13",
|
"open-props": "^1.5.13",
|
||||||
"radix-svelte": "^0.9.0",
|
"radix-svelte": "^0.9.0",
|
||||||
|
|
|
||||||
3037
pnpm-lock.yaml
3037
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
2
src/app.d.ts
vendored
2
src/app.d.ts
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
// for information about these interfaces
|
// for information about these interfaces
|
||||||
// and what to do when importing types
|
// and what to do when importing types
|
||||||
|
|
||||||
import type { User } from '@prisma/client';
|
import type { PrismaClient, User } from '@prisma/client';
|
||||||
|
|
||||||
type User = Omit<User, 'created_at' | 'updated_at'>;
|
type User = Omit<User, 'created_at' | 'updated_at'>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
import * as Sentry from '@sentry/sveltekit';
|
import * as Sentry from '@sentry/sveltekit';
|
||||||
import { sequence } from '@sveltejs/kit/hooks';
|
import { sequence } from '@sveltejs/kit/hooks';
|
||||||
import { PrismaClient } from '@prisma/client';
|
|
||||||
import type { Handle } from '@sveltejs/kit';
|
import type { Handle } from '@sveltejs/kit';
|
||||||
import { auth } from '$lib/server/lucia';
|
|
||||||
import { dev } from '$app/environment';
|
import { dev } from '$app/environment';
|
||||||
|
import { auth } from '$lib/server/lucia';
|
||||||
|
|
||||||
Sentry.init({
|
Sentry.init({
|
||||||
dsn: 'https://742e43279df93a3c4a4a78c12eb1f879@o4506057768632320.ingest.sentry.io/4506057770401792',
|
dsn: 'https://742e43279df93a3c4a4a78c12eb1f879@o4506057768632320.ingest.sentry.io/4506057770401792',
|
||||||
|
|
@ -11,10 +10,6 @@ Sentry.init({
|
||||||
environment: dev ? 'development' : 'production'
|
environment: dev ? 'development' : 'production'
|
||||||
});
|
});
|
||||||
|
|
||||||
// * START UP
|
|
||||||
// RUNS ONCE ON FILE LOAD
|
|
||||||
export const prisma_client = new PrismaClient();
|
|
||||||
|
|
||||||
export const authentication: Handle = async function ({ event, resolve }) {
|
export const authentication: Handle = async function ({ event, resolve }) {
|
||||||
const startTimer = Date.now();
|
const startTimer = Date.now();
|
||||||
event.locals.startTimer = startTimer;
|
event.locals.startTimer = startTimer;
|
||||||
|
|
@ -22,9 +17,11 @@ export const authentication: Handle = async function ({ event, resolve }) {
|
||||||
event.locals.auth = auth.handleRequest(event);
|
event.locals.auth = auth.handleRequest(event);
|
||||||
if (event?.locals?.auth) {
|
if (event?.locals?.auth) {
|
||||||
console.log('auth not empty');
|
console.log('auth not empty');
|
||||||
|
console.log('auth', event.locals.auth);
|
||||||
try {
|
try {
|
||||||
const session = await event.locals.auth.validate();
|
const session = await event.locals.auth.validate();
|
||||||
console.log('user', session?.user);
|
console.log('user', session?.user);
|
||||||
|
console.log('session', JSON.stringify(session, null, 2));
|
||||||
event.locals.user = session?.user;
|
event.locals.user = session?.user;
|
||||||
// if (event.route.id?.startsWith('/(protected)')) {
|
// if (event.route.id?.startsWith('/(protected)')) {
|
||||||
// if (!user) throw redirect(302, '/sign-in');
|
// if (!user) throw redirect(302, '/sign-in');
|
||||||
|
|
@ -36,23 +33,25 @@ export const authentication: Handle = async function ({ event, resolve }) {
|
||||||
} else {
|
} else {
|
||||||
console.log('auth empty');
|
console.log('auth empty');
|
||||||
}
|
}
|
||||||
|
|
||||||
return await resolve(event);
|
return await resolve(event);
|
||||||
};
|
};
|
||||||
|
|
||||||
// This hook is used to pass our prisma instance to each action, load, and endpoint
|
// This hook is used to pass our prisma instance to each action, load, and endpoint
|
||||||
export const prisma: Handle = async function ({ event, resolve }) {
|
// export const prisma: Handle = async function ({ event, resolve }) {
|
||||||
const ip = event.request.headers.get('x-forwarded-for') as string;
|
// try {
|
||||||
const country = event.request.headers.get('x-vercel-ip-country') as string;
|
// const ip = event.request.headers.get('x-forwarded-for') as string;
|
||||||
event.locals.prisma = prisma_client;
|
// const country = event.request.headers.get('x-vercel-ip-country') as string;
|
||||||
event.locals.session = {
|
// event.locals.prisma = prisma_client;
|
||||||
...event.locals.session,
|
// event.locals.session = {
|
||||||
ip,
|
// ...event.locals.session,
|
||||||
country
|
// ip,
|
||||||
};
|
// country
|
||||||
const response = await resolve(event);
|
// };
|
||||||
return response;
|
// } catch (error) {
|
||||||
};
|
// console.error(error);
|
||||||
|
// }
|
||||||
|
// return await resolve(event);
|
||||||
|
// };
|
||||||
|
|
||||||
export const handle = sequence(sequence(Sentry.sentryHandle(), authentication, prisma));
|
export const handle: Handle = sequence(sequence(Sentry.sentryHandle(), authentication));
|
||||||
export const handleError = Sentry.handleErrorWithSentry();
|
export const handleError = Sentry.handleErrorWithSentry();
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Form as FormPrimitive } from "formsnap";
|
import { Form as FormPrimitive } from "formsnap";
|
||||||
import { buttonVariants } from "$lib/components/ui/button";
|
import { buttonVariants } from "$lib/components/ui/button";
|
||||||
import { cn } from "@/utils";
|
import { cn } from "$lib/utils";
|
||||||
import { ChevronDown } from "lucide-svelte";
|
import { ChevronDown } from "lucide-svelte";
|
||||||
import type { HTMLSelectAttributes } from "svelte/elements";
|
import type { HTMLSelectAttributes } from "svelte/elements";
|
||||||
|
|
||||||
|
|
|
||||||
4
src/lib/prisma.ts
Normal file
4
src/lib/prisma.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
import { PrismaClient } from '@prisma/client'
|
||||||
|
|
||||||
|
const prisma = new PrismaClient()
|
||||||
|
export default prisma
|
||||||
|
|
@ -3,12 +3,14 @@ import { lucia } from 'lucia';
|
||||||
import { sveltekit } from 'lucia/middleware';
|
import { sveltekit } from 'lucia/middleware';
|
||||||
import { prisma } from '@lucia-auth/adapter-prisma';
|
import { prisma } from '@lucia-auth/adapter-prisma';
|
||||||
import { dev } from '$app/environment';
|
import { dev } from '$app/environment';
|
||||||
import { PrismaClient } from '@prisma/client';
|
import prisma_client from '$lib/prisma';
|
||||||
|
|
||||||
|
// export const prisma_client = new PrismaClient();
|
||||||
|
|
||||||
export const auth = lucia({
|
export const auth = lucia({
|
||||||
env: dev ? 'DEV' : 'PROD',
|
env: dev ? 'DEV' : 'PROD',
|
||||||
middleware: sveltekit(),
|
middleware: sveltekit(),
|
||||||
adapter: prisma(new PrismaClient()),
|
adapter: prisma(prisma_client),
|
||||||
getUserAttributes: (databaseUser) => {
|
getUserAttributes: (databaseUser) => {
|
||||||
return {
|
return {
|
||||||
username: databaseUser.username,
|
username: databaseUser.username,
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
import type { Game } from '@prisma/client';
|
import type { Game } from '@prisma/client';
|
||||||
import kebabCase from 'just-kebab-case';
|
import kebabCase from 'just-kebab-case';
|
||||||
import type { BggLinkDto } from 'boardgamegeekclient/dist/esm/dto/concrete/subdto';
|
import type { BggLinkDto } from 'boardgamegeekclient/dist/esm/dto/concrete/subdto';
|
||||||
|
import prisma from '$lib/prisma';
|
||||||
import { mapAPIGameToBoredGame } from './gameMapper';
|
import { mapAPIGameToBoredGame } from './gameMapper';
|
||||||
|
|
||||||
export async function createArtist(locals: App.Locals, externalArtist: BggLinkDto) {
|
export async function createArtist(locals: App.Locals, externalArtist: BggLinkDto) {
|
||||||
try {
|
try {
|
||||||
let dbArtist = await locals.prisma.artist.findFirst({
|
let dbArtist = await prisma.artist.findFirst({
|
||||||
where: {
|
where: {
|
||||||
external_id: externalArtist.id
|
external_id: externalArtist.id
|
||||||
},
|
},
|
||||||
|
|
@ -21,7 +22,7 @@ export async function createArtist(locals: App.Locals, externalArtist: BggLinkDt
|
||||||
return dbArtist;
|
return dbArtist;
|
||||||
}
|
}
|
||||||
console.log('Creating artist', JSON.stringify(externalArtist, null, 2));
|
console.log('Creating artist', JSON.stringify(externalArtist, null, 2));
|
||||||
let artist = await locals.prisma.artist.create({
|
let artist = await prisma.artist.create({
|
||||||
data: {
|
data: {
|
||||||
name: externalArtist.value,
|
name: externalArtist.value,
|
||||||
external_id: externalArtist.id,
|
external_id: externalArtist.id,
|
||||||
|
|
@ -45,7 +46,7 @@ export async function createArtist(locals: App.Locals, externalArtist: BggLinkDt
|
||||||
|
|
||||||
export async function createDesigner(locals: App.Locals, externalDesigner: BggLinkDto) {
|
export async function createDesigner(locals: App.Locals, externalDesigner: BggLinkDto) {
|
||||||
try {
|
try {
|
||||||
let dbDesigner = await locals.prisma.designer.findFirst({
|
let dbDesigner = await prisma.designer.findFirst({
|
||||||
where: {
|
where: {
|
||||||
external_id: externalDesigner.id
|
external_id: externalDesigner.id
|
||||||
},
|
},
|
||||||
|
|
@ -61,7 +62,7 @@ export async function createDesigner(locals: App.Locals, externalDesigner: BggLi
|
||||||
return dbDesigner;
|
return dbDesigner;
|
||||||
}
|
}
|
||||||
console.log('Creating designer', JSON.stringify(externalDesigner, null, 2));
|
console.log('Creating designer', JSON.stringify(externalDesigner, null, 2));
|
||||||
let designer = await locals.prisma.designer.create({
|
let designer = await prisma.designer.create({
|
||||||
data: {
|
data: {
|
||||||
name: externalDesigner.value,
|
name: externalDesigner.value,
|
||||||
external_id: externalDesigner.id,
|
external_id: externalDesigner.id,
|
||||||
|
|
@ -85,7 +86,7 @@ export async function createDesigner(locals: App.Locals, externalDesigner: BggLi
|
||||||
|
|
||||||
export async function createPublisher(locals: App.Locals, externalPublisher: BggLinkDto) {
|
export async function createPublisher(locals: App.Locals, externalPublisher: BggLinkDto) {
|
||||||
try {
|
try {
|
||||||
let dbPublisher = await locals.prisma.publisher.findFirst({
|
let dbPublisher = await prisma.publisher.findFirst({
|
||||||
where: {
|
where: {
|
||||||
external_id: externalPublisher.id
|
external_id: externalPublisher.id
|
||||||
},
|
},
|
||||||
|
|
@ -101,7 +102,7 @@ export async function createPublisher(locals: App.Locals, externalPublisher: Bgg
|
||||||
return dbPublisher;
|
return dbPublisher;
|
||||||
}
|
}
|
||||||
console.log('Creating publisher', JSON.stringify(externalPublisher, null, 2));
|
console.log('Creating publisher', JSON.stringify(externalPublisher, null, 2));
|
||||||
let publisher = await locals.prisma.publisher.create({
|
let publisher = await prisma.publisher.create({
|
||||||
data: {
|
data: {
|
||||||
name: externalPublisher.value,
|
name: externalPublisher.value,
|
||||||
external_id: externalPublisher.id,
|
external_id: externalPublisher.id,
|
||||||
|
|
@ -125,7 +126,7 @@ export async function createPublisher(locals: App.Locals, externalPublisher: Bgg
|
||||||
|
|
||||||
export async function createCategory(locals: App.Locals, externalCategory: BggLinkDto) {
|
export async function createCategory(locals: App.Locals, externalCategory: BggLinkDto) {
|
||||||
try {
|
try {
|
||||||
let dbCategory = await locals.prisma.category.findFirst({
|
let dbCategory = await prisma.category.findFirst({
|
||||||
where: {
|
where: {
|
||||||
external_id: externalCategory.id
|
external_id: externalCategory.id
|
||||||
},
|
},
|
||||||
|
|
@ -141,7 +142,7 @@ export async function createCategory(locals: App.Locals, externalCategory: BggLi
|
||||||
return dbCategory;
|
return dbCategory;
|
||||||
}
|
}
|
||||||
console.log('Creating category', JSON.stringify(externalCategory, null, 2));
|
console.log('Creating category', JSON.stringify(externalCategory, null, 2));
|
||||||
let category = await locals.prisma.category.create({
|
let category = await prisma.category.create({
|
||||||
data: {
|
data: {
|
||||||
name: externalCategory.value,
|
name: externalCategory.value,
|
||||||
external_id: externalCategory.id,
|
external_id: externalCategory.id,
|
||||||
|
|
@ -166,7 +167,7 @@ export async function createCategory(locals: App.Locals, externalCategory: BggLi
|
||||||
|
|
||||||
export async function createMechanic(locals: App.Locals, externalMechanic: BggLinkDto) {
|
export async function createMechanic(locals: App.Locals, externalMechanic: BggLinkDto) {
|
||||||
try {
|
try {
|
||||||
let dbMechanic = await locals.prisma.mechanic.findFirst({
|
let dbMechanic = await prisma.mechanic.findFirst({
|
||||||
where: {
|
where: {
|
||||||
external_id: externalMechanic.id
|
external_id: externalMechanic.id
|
||||||
},
|
},
|
||||||
|
|
@ -182,7 +183,7 @@ export async function createMechanic(locals: App.Locals, externalMechanic: BggLi
|
||||||
return dbMechanic;
|
return dbMechanic;
|
||||||
}
|
}
|
||||||
console.log('Creating mechanic', JSON.stringify(externalMechanic, null, 2));
|
console.log('Creating mechanic', JSON.stringify(externalMechanic, null, 2));
|
||||||
let mechanic = await locals.prisma.mechanic.upsert({
|
let mechanic = await prisma.mechanic.upsert({
|
||||||
where: {
|
where: {
|
||||||
external_id: externalMechanic.id
|
external_id: externalMechanic.id
|
||||||
},
|
},
|
||||||
|
|
@ -214,7 +215,7 @@ export async function createExpansion(
|
||||||
eventFetch: Function
|
eventFetch: Function
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
let dbExpansionGame = await locals.prisma.game.findUnique({
|
let dbExpansionGame = await prisma.game.findUnique({
|
||||||
where: {
|
where: {
|
||||||
external_id: externalExpansion.id
|
external_id: externalExpansion.id
|
||||||
}
|
}
|
||||||
|
|
@ -244,7 +245,7 @@ export async function createExpansion(
|
||||||
'External expansion is expansion. Looking for base game',
|
'External expansion is expansion. Looking for base game',
|
||||||
JSON.stringify(game, null, 2)
|
JSON.stringify(game, null, 2)
|
||||||
);
|
);
|
||||||
dbExpansion = await locals.prisma.expansion.findFirst({
|
dbExpansion = await prisma.expansion.findFirst({
|
||||||
where: {
|
where: {
|
||||||
game_id: dbExpansionGame.id
|
game_id: dbExpansionGame.id
|
||||||
},
|
},
|
||||||
|
|
@ -261,7 +262,7 @@ export async function createExpansion(
|
||||||
'External Expansion is base game. Looking for expansion',
|
'External Expansion is base game. Looking for expansion',
|
||||||
JSON.stringify(game, null, 2)
|
JSON.stringify(game, null, 2)
|
||||||
);
|
);
|
||||||
dbExpansion = await locals.prisma.expansion.findFirst({
|
dbExpansion = await prisma.expansion.findFirst({
|
||||||
where: {
|
where: {
|
||||||
base_game_id: dbExpansionGame.id
|
base_game_id: dbExpansionGame.id
|
||||||
},
|
},
|
||||||
|
|
@ -281,7 +282,7 @@ export async function createExpansion(
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Creating expansion. baseGameId: ${baseGameId}, gameId: ${gameId}`);
|
console.log(`Creating expansion. baseGameId: ${baseGameId}, gameId: ${gameId}`);
|
||||||
let expansion = await locals.prisma.expansion.create({
|
let expansion = await prisma.expansion.create({
|
||||||
data: {
|
data: {
|
||||||
base_game_id: baseGameId,
|
base_game_id: baseGameId,
|
||||||
game_id: gameId
|
game_id: gameId
|
||||||
|
|
@ -292,7 +293,7 @@ export async function createExpansion(
|
||||||
|
|
||||||
if (gameIsExpansion) {
|
if (gameIsExpansion) {
|
||||||
console.log('Connecting current game to expansion');
|
console.log('Connecting current game to expansion');
|
||||||
await locals.prisma.game.update({
|
await prisma.game.update({
|
||||||
where: {
|
where: {
|
||||||
id: gameId
|
id: gameId
|
||||||
},
|
},
|
||||||
|
|
@ -306,9 +307,9 @@ export async function createExpansion(
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log('Connecting current game to base game');
|
console.log('Connecting current game to base game');
|
||||||
await locals.prisma.game.update({
|
await prisma.game.update({
|
||||||
where: {
|
where: {
|
||||||
external_id: baseGameId
|
id: baseGameId
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
expansions: {
|
expansions: {
|
||||||
|
|
@ -330,7 +331,7 @@ export async function createExpansion(
|
||||||
export async function createOrUpdateGameMinimal(locals: App.Locals, game: Game) {
|
export async function createOrUpdateGameMinimal(locals: App.Locals, game: Game) {
|
||||||
console.log('Creating or updating minimal game data', JSON.stringify(game, null, 2));
|
console.log('Creating or updating minimal game data', JSON.stringify(game, null, 2));
|
||||||
const externalUrl = `https://boardgamegeek.com/boardgame/${game.external_id}`;
|
const externalUrl = `https://boardgamegeek.com/boardgame/${game.external_id}`;
|
||||||
return await locals.prisma.game.upsert({
|
return await prisma.game.upsert({
|
||||||
where: {
|
where: {
|
||||||
external_id: game.external_id
|
external_id: game.external_id
|
||||||
},
|
},
|
||||||
|
|
@ -378,7 +379,7 @@ export async function createOrUpdateGame(locals: App.Locals, game: Game) {
|
||||||
const externalUrl = `https://boardgamegeek.com/boardgame/${game.external_id}`;
|
const externalUrl = `https://boardgamegeek.com/boardgame/${game.external_id}`;
|
||||||
console.log('categoryIds', categoryIds);
|
console.log('categoryIds', categoryIds);
|
||||||
console.log('mechanicIds', mechanicIds);
|
console.log('mechanicIds', mechanicIds);
|
||||||
return await locals.prisma.game.upsert({
|
return await prisma.game.upsert({
|
||||||
include: {
|
include: {
|
||||||
mechanics: true,
|
mechanics: true,
|
||||||
publishers: true,
|
publishers: true,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { error, fail, redirect } from '@sveltejs/kit';
|
import { error, fail, redirect } from '@sveltejs/kit';
|
||||||
import { superValidate } from 'sveltekit-superforms/server';
|
import { superValidate } from 'sveltekit-superforms/server';
|
||||||
import type { PageServerLoad } from '../../$types.js';
|
import type { PageServerLoad } from '../../$types.js';
|
||||||
|
import prisma from '$lib/prisma';
|
||||||
import { modifyListGameSchema, type ListGame } from '$lib/config/zod-schemas.js';
|
import { modifyListGameSchema, type ListGame } from '$lib/config/zod-schemas.js';
|
||||||
import { search_schema } from '$lib/zodValidation.js';
|
import { search_schema } from '$lib/zodValidation.js';
|
||||||
|
|
||||||
|
|
@ -27,7 +28,7 @@ export const load: PageServerLoad = async ({ fetch, url, locals }) => {
|
||||||
const listManageForm = await superValidate(modifyListGameSchema);
|
const listManageForm = await superValidate(modifyListGameSchema);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let collection = await locals.prisma.collection.findUnique({
|
let collection = await prisma.collection.findUnique({
|
||||||
where: {
|
where: {
|
||||||
user_id: session.user.userId
|
user_id: session.user.userId
|
||||||
}
|
}
|
||||||
|
|
@ -37,14 +38,14 @@ export const load: PageServerLoad = async ({ fetch, url, locals }) => {
|
||||||
if (!collection) {
|
if (!collection) {
|
||||||
console.log('Collection was not found');
|
console.log('Collection was not found');
|
||||||
return fail(404, {});
|
return fail(404, {});
|
||||||
// collection = await locals.prisma.collection.create({
|
// collection = await prisma.collection.create({
|
||||||
// data: {
|
// data: {
|
||||||
// user_id: session.userId
|
// user_id: session.userId
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
let collection_items = await locals.prisma.collectionItem.findMany({
|
let collection_items = await prisma.collectionItem.findMany({
|
||||||
where: {
|
where: {
|
||||||
collection_id: collection.id
|
collection_id: collection.id
|
||||||
},
|
},
|
||||||
|
|
@ -108,14 +109,14 @@ export const actions = {
|
||||||
throw redirect(302, '/login');
|
throw redirect(302, '/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
let game = await locals.prisma.game.findUnique({
|
let game = await prisma.game.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: form.data.id
|
id: form.data.id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!game) {
|
if (!game) {
|
||||||
// game = await locals.prisma.game.create({
|
// game = await prisma.game.create({
|
||||||
// data: {
|
// data: {
|
||||||
// name: form.name
|
// name: form.name
|
||||||
// }
|
// }
|
||||||
|
|
@ -125,7 +126,7 @@ export const actions = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game) {
|
if (game) {
|
||||||
const collection = await locals.prisma.collection.findUnique({
|
const collection = await prisma.collection.findUnique({
|
||||||
where: {
|
where: {
|
||||||
user_id: session.user.userId
|
user_id: session.user.userId
|
||||||
}
|
}
|
||||||
|
|
@ -136,7 +137,7 @@ export const actions = {
|
||||||
return error(404, 'Wishlist not found');
|
return error(404, 'Wishlist not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
await locals.prisma.collectionItem.create({
|
await prisma.collectionItem.create({
|
||||||
data: {
|
data: {
|
||||||
game_id: game.id,
|
game_id: game.id,
|
||||||
collection_id: collection.id,
|
collection_id: collection.id,
|
||||||
|
|
@ -180,14 +181,14 @@ export const actions = {
|
||||||
throw redirect(302, '/login');
|
throw redirect(302, '/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
let game = await locals.prisma.game.findUnique({
|
let game = await prisma.game.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: form.data.id
|
id: form.data.id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!game) {
|
if (!game) {
|
||||||
// game = await locals.prisma.game.create({
|
// game = await prisma.game.create({
|
||||||
// data: {
|
// data: {
|
||||||
// name: form.name
|
// name: form.name
|
||||||
// }
|
// }
|
||||||
|
|
@ -197,7 +198,7 @@ export const actions = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game) {
|
if (game) {
|
||||||
const collection = await locals.prisma.collection.findUnique({
|
const collection = await prisma.collection.findUnique({
|
||||||
where: {
|
where: {
|
||||||
user_id: session.user.userId
|
user_id: session.user.userId
|
||||||
}
|
}
|
||||||
|
|
@ -208,7 +209,7 @@ export const actions = {
|
||||||
return error(404, 'Wishlist not found');
|
return error(404, 'Wishlist not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
await locals.prisma.collectionItem.delete({
|
await prisma.collectionItem.delete({
|
||||||
where: {
|
where: {
|
||||||
collection_id: collection.id,
|
collection_id: collection.id,
|
||||||
game_id: game.id
|
game_id: game.id
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { redirect } from '@sveltejs/kit';
|
import { redirect } from '@sveltejs/kit';
|
||||||
|
import prisma from '$lib/prisma';
|
||||||
|
|
||||||
export async function load({ locals }) {
|
export async function load({ locals }) {
|
||||||
const session = await locals.auth.validate();
|
const session = await locals.auth.validate();
|
||||||
|
|
@ -7,14 +8,14 @@ export async function load({ locals }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let wishlists = await locals.prisma.wishlist.findMany({
|
let wishlists = await prisma.wishlist.findMany({
|
||||||
where: {
|
where: {
|
||||||
user_id: session.userId
|
user_id: session.userId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (wishlists.length === 0) {
|
if (wishlists.length === 0) {
|
||||||
const wishlist = await locals.prisma.wishlist.create({
|
const wishlist = await prisma.wishlist.create({
|
||||||
data: {
|
data: {
|
||||||
user_id: session.userId
|
user_id: session.userId
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { fail, redirect } from '@sveltejs/kit';
|
import { fail, redirect } from '@sveltejs/kit';
|
||||||
import { superValidate } from 'sveltekit-superforms/server';
|
import { superValidate } from 'sveltekit-superforms/server';
|
||||||
|
import prisma from '$lib/prisma';
|
||||||
|
|
||||||
export async function load({ params, locals }) {
|
export async function load({ params, locals }) {
|
||||||
const session = await locals.auth.validate();
|
const session = await locals.auth.validate();
|
||||||
|
|
@ -8,7 +9,7 @@ export async function load({ params, locals }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let wishlist = await locals.prisma.wishlist.findUnique({
|
let wishlist = await prisma.wishlist.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: params.id,
|
id: params.id,
|
||||||
AND: {
|
AND: {
|
||||||
|
|
@ -50,14 +51,14 @@ export const actions = {
|
||||||
throw redirect(302, '/login');
|
throw redirect(302, '/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
let game = await locals.prisma.game.findUnique({
|
let game = await prisma.game.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: form.id
|
id: form.id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!game) {
|
if (!game) {
|
||||||
// game = await locals.prisma.game.create({
|
// game = await prisma.game.create({
|
||||||
// data: {
|
// data: {
|
||||||
// name: form.name
|
// name: form.name
|
||||||
// }
|
// }
|
||||||
|
|
@ -67,7 +68,7 @@ export const actions = {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const wishlist = await locals.prisma.wishlist.findUnique({
|
const wishlist = await prisma.wishlist.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: params.id
|
id: params.id
|
||||||
}
|
}
|
||||||
|
|
@ -83,7 +84,7 @@ export const actions = {
|
||||||
throw redirect(302, '/404');
|
throw redirect(302, '/404');
|
||||||
}
|
}
|
||||||
|
|
||||||
const wishlistItem = await locals.prisma.wishlistItem.create({
|
const wishlistItem = await prisma.wishlistItem.create({
|
||||||
data: {
|
data: {
|
||||||
game_id: game.id,
|
game_id: game.id,
|
||||||
wishlist_id: wishlist.id
|
wishlist_id: wishlist.id
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { error, redirect } from '@sveltejs/kit';
|
import { error, redirect } from '@sveltejs/kit';
|
||||||
import { superValidate } from 'sveltekit-superforms/server';
|
import { superValidate } from 'sveltekit-superforms/server';
|
||||||
|
import prisma from '$lib/prisma';
|
||||||
import { modifyListGameSchema } from '$lib/config/zod-schemas.js';
|
import { modifyListGameSchema } from '$lib/config/zod-schemas.js';
|
||||||
|
|
||||||
export async function load({ params, locals }) {
|
export async function load({ params, locals }) {
|
||||||
|
|
@ -11,7 +12,7 @@ export async function load({ params, locals }) {
|
||||||
console.log('Wishlist load User id', session.user);
|
console.log('Wishlist load User id', session.user);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let wishlist = await locals.prisma.wishlist.findUnique({
|
let wishlist = await prisma.wishlist.findUnique({
|
||||||
where: {
|
where: {
|
||||||
user_id: session?.user?.userId
|
user_id: session?.user?.userId
|
||||||
},
|
},
|
||||||
|
|
@ -57,14 +58,14 @@ export const actions = {
|
||||||
throw redirect(302, '/login');
|
throw redirect(302, '/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
let game = await locals.prisma.game.findUnique({
|
let game = await prisma.game.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: form.data.id
|
id: form.data.id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!game) {
|
if (!game) {
|
||||||
// game = await locals.prisma.game.create({
|
// game = await prisma.game.create({
|
||||||
// data: {
|
// data: {
|
||||||
// name: form.name
|
// name: form.name
|
||||||
// }
|
// }
|
||||||
|
|
@ -74,7 +75,7 @@ export const actions = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game) {
|
if (game) {
|
||||||
const wishlist = await locals.prisma.wishlist.findUnique({
|
const wishlist = await prisma.wishlist.findUnique({
|
||||||
where: {
|
where: {
|
||||||
user_id: session.user.userId
|
user_id: session.user.userId
|
||||||
}
|
}
|
||||||
|
|
@ -85,7 +86,7 @@ export const actions = {
|
||||||
return error(404, 'Wishlist not found');
|
return error(404, 'Wishlist not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
await locals.prisma.wishlistItem.create({
|
await prisma.wishlistItem.create({
|
||||||
data: {
|
data: {
|
||||||
game_id: game.id,
|
game_id: game.id,
|
||||||
wishlist_id: wishlist.id
|
wishlist_id: wishlist.id
|
||||||
|
|
@ -128,14 +129,14 @@ export const actions = {
|
||||||
throw redirect(302, '/login');
|
throw redirect(302, '/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
let game = await locals.prisma.game.findUnique({
|
let game = await prisma.game.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: form.data.id
|
id: form.data.id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!game) {
|
if (!game) {
|
||||||
// game = await locals.prisma.game.create({
|
// game = await prisma.game.create({
|
||||||
// data: {
|
// data: {
|
||||||
// name: form.name
|
// name: form.name
|
||||||
// }
|
// }
|
||||||
|
|
@ -145,7 +146,7 @@ export const actions = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game) {
|
if (game) {
|
||||||
const wishlist = await locals.prisma.wishlist.findUnique({
|
const wishlist = await prisma.wishlist.findUnique({
|
||||||
where: {
|
where: {
|
||||||
user_id: session.user.userId
|
user_id: session.user.userId
|
||||||
}
|
}
|
||||||
|
|
@ -156,7 +157,7 @@ export const actions = {
|
||||||
return error(404, 'Wishlist not found');
|
return error(404, 'Wishlist not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
await locals.prisma.wishlistItem.delete({
|
await prisma.wishlistItem.delete({
|
||||||
where: {
|
where: {
|
||||||
wishlist_id: wishlist.id,
|
wishlist_id: wishlist.id,
|
||||||
game_id: game.id
|
game_id: game.id
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
|
import type { Game } from '@prisma/client';
|
||||||
import {
|
import {
|
||||||
createArtist,
|
createArtist,
|
||||||
createCategory,
|
createCategory,
|
||||||
|
|
@ -9,13 +10,13 @@ import {
|
||||||
createPublisher
|
createPublisher
|
||||||
} from '$lib/utils/dbUtils.js';
|
} from '$lib/utils/dbUtils.js';
|
||||||
import { mapAPIGameToBoredGame } from '$lib/utils/gameMapper.js';
|
import { mapAPIGameToBoredGame } from '$lib/utils/gameMapper.js';
|
||||||
import type { Game } from '@prisma/client';
|
import prisma from '$lib/prisma';
|
||||||
|
|
||||||
export const load = async ({ params, locals, fetch }) => {
|
export const load = async ({ params, locals, fetch }) => {
|
||||||
try {
|
try {
|
||||||
const { user } = locals;
|
const { user } = locals;
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
const game = await locals.prisma.game.findUnique({
|
const game = await prisma.game.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id
|
id
|
||||||
},
|
},
|
||||||
|
|
@ -64,7 +65,7 @@ export const load = async ({ params, locals, fetch }) => {
|
||||||
let wishlist;
|
let wishlist;
|
||||||
let collection;
|
let collection;
|
||||||
if (user) {
|
if (user) {
|
||||||
wishlist = await locals.prisma.wishlist.findUnique({
|
wishlist = await prisma.wishlist.findUnique({
|
||||||
where: {
|
where: {
|
||||||
user_id: user.userId
|
user_id: user.userId
|
||||||
},
|
},
|
||||||
|
|
@ -77,7 +78,7 @@ export const load = async ({ params, locals, fetch }) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
collection = await locals.prisma.collection.findUnique({
|
collection = await prisma.collection.findUnique({
|
||||||
where: {
|
where: {
|
||||||
user_id: user.userId
|
user_id: user.userId
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
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 = async ({ url, locals }) => {
|
||||||
return {
|
return {
|
||||||
url: url.pathname,
|
url: url.pathname,
|
||||||
user: locals.user
|
user: locals.user
|
||||||
};
|
};
|
||||||
});
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { fail } from '@sveltejs/kit';
|
import { fail } from '@sveltejs/kit';
|
||||||
import { setError, superValidate } from 'sveltekit-superforms/server';
|
import { setError, superValidate } from 'sveltekit-superforms/server';
|
||||||
import { redirect } from 'sveltekit-flash-message/server';
|
import { redirect } from 'sveltekit-flash-message/server';
|
||||||
|
import prisma from '$lib/prisma';
|
||||||
import { auth } from '$lib/server/lucia';
|
import { auth } from '$lib/server/lucia';
|
||||||
import { userSchema } from '$lib/config/zod-schemas';
|
import { userSchema } from '$lib/config/zod-schemas';
|
||||||
|
|
||||||
|
|
@ -10,16 +11,22 @@ const signInSchema = userSchema.pick({
|
||||||
});
|
});
|
||||||
|
|
||||||
export const load = async (event) => {
|
export const load = async (event) => {
|
||||||
console.log('login load event', event);
|
|
||||||
const session = await event.locals.auth.validate();
|
|
||||||
if (session) {
|
|
||||||
const message = { type: 'info', message: 'You are already signed in' };
|
|
||||||
throw redirect('/', message, event);
|
|
||||||
}
|
|
||||||
const form = await superValidate(event, signInSchema);
|
const form = await superValidate(event, signInSchema);
|
||||||
return {
|
try {
|
||||||
form
|
console.log('login load event', event);
|
||||||
};
|
const session = await event.locals.auth.validate();
|
||||||
|
if (session) {
|
||||||
|
const message = { type: 'info', message: 'You are already signed in' };
|
||||||
|
throw redirect('/', message, event);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
form
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
fail(500, {
|
||||||
|
form
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
|
|
@ -42,7 +49,7 @@ export const actions = {
|
||||||
});
|
});
|
||||||
event.locals.auth.setSession(session);
|
event.locals.auth.setSession(session);
|
||||||
|
|
||||||
const user = await locals.prisma.user.findUnique({
|
const user = await prisma.user.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: session.user.userId
|
id: session.user.userId
|
||||||
},
|
},
|
||||||
|
|
@ -55,7 +62,7 @@ export const actions = {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (user) {
|
if (user) {
|
||||||
await locals.prisma.collection.upsert({
|
await prisma.collection.upsert({
|
||||||
where: {
|
where: {
|
||||||
user_id: user.id
|
user_id: user.id
|
||||||
},
|
},
|
||||||
|
|
@ -66,7 +73,7 @@ export const actions = {
|
||||||
user_id: user.id
|
user_id: user.id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
await locals.prisma.wishlist.upsert({
|
await prisma.wishlist.upsert({
|
||||||
where: {
|
where: {
|
||||||
user_id: user.id
|
user_id: user.id
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -32,15 +32,15 @@
|
||||||
delayMs: 0,
|
delayMs: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
const flash = flashModule.getFlash(page);
|
// const flash = flashModule.getFlash(page);
|
||||||
|
|
||||||
$: {
|
// $: {
|
||||||
if ($flash) {
|
// if ($flash) {
|
||||||
toast.error($flash.message, {
|
// toast.error($flash.message, {
|
||||||
duration: 5000
|
// duration: 5000
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { fail, redirect, error } from '@sveltejs/kit';
|
import { fail, redirect, error } from '@sveltejs/kit';
|
||||||
import { superValidate } from 'sveltekit-superforms/server';
|
import { superValidate } from 'sveltekit-superforms/server';
|
||||||
import { LuciaError } from 'lucia';
|
import { LuciaError } from 'lucia';
|
||||||
|
import prisma from '$lib/prisma';
|
||||||
import { auth } from '$lib/server/lucia';
|
import { auth } from '$lib/server/lucia';
|
||||||
import { userSchema } from '$lib/config/zod-schemas';
|
import { userSchema } from '$lib/config/zod-schemas';
|
||||||
import { add_user_to_role } from '$server/roles';
|
import { add_user_to_role } from '$server/roles';
|
||||||
|
|
@ -33,10 +34,10 @@ const signUpSchema = userSchema
|
||||||
|
|
||||||
export const load = async (event) => {
|
export const load = async (event) => {
|
||||||
console.log('sign up load event', event);
|
console.log('sign up load event', event);
|
||||||
const session = await event.locals.auth.validate();
|
// const session = await event.locals.auth.validate();
|
||||||
if (session) {
|
// if (session) {
|
||||||
throw redirect(302, '/');
|
// throw redirect(302, '/');
|
||||||
}
|
// }
|
||||||
return {
|
return {
|
||||||
form: await superValidate<typeof signUpSchema, Message>(event, signUpSchema)
|
form: await superValidate<typeof signUpSchema, Message>(event, signUpSchema)
|
||||||
};
|
};
|
||||||
|
|
@ -78,12 +79,12 @@ export const actions = {
|
||||||
});
|
});
|
||||||
console.log('signup user', user);
|
console.log('signup user', user);
|
||||||
add_user_to_role(user.userId, 'user');
|
add_user_to_role(user.userId, 'user');
|
||||||
await locals.prisma.collection.create({
|
await prisma.collection.create({
|
||||||
data: {
|
data: {
|
||||||
user_id: user.userId
|
user_id: user.userId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
await locals.prisma.wishlist.create({
|
await prisma.wishlist.create({
|
||||||
data: {
|
data: {
|
||||||
user_id: user.userId
|
user_id: user.userId
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,15 +31,15 @@
|
||||||
delayMs: 0,
|
delayMs: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
const flash = flashModule.getFlash(page);
|
// const flash = flashModule.getFlash(page);
|
||||||
|
|
||||||
$: {
|
// $: {
|
||||||
if ($flash) {
|
// if ($flash) {
|
||||||
toast.error($flash.message, {
|
// toast.error($flash.message, {
|
||||||
duration: 5000
|
// duration: 5000
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import "$lib/styles/app.pcss";
|
import "$lib/styles/app.pcss";
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import { getFlash } from 'sveltekit-flash-message/client';
|
// import { getFlash } from 'sveltekit-flash-message/client';
|
||||||
import toast, { Toaster } from 'svelte-french-toast';
|
import toast, { Toaster } from 'svelte-french-toast';
|
||||||
import { navigating, page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
import { MetaTags } from 'svelte-meta-tags';
|
import { MetaTags } from 'svelte-meta-tags';
|
||||||
import debounce from 'just-debounce-it';
|
|
||||||
import 'iconify-icon';
|
import 'iconify-icon';
|
||||||
import Analytics from '$lib/components/analytics.svelte';
|
import Analytics from '$lib/components/analytics.svelte';
|
||||||
import Portal from "$lib/Portal.svelte";
|
|
||||||
import Loading from "$components/loading.svelte";
|
|
||||||
import { boredState } from '$lib/stores/boredState';
|
|
||||||
import { theme } from '$state/theme';
|
import { theme } from '$state/theme';
|
||||||
|
|
||||||
const dev = process.env.NODE_ENV !== 'production';
|
const dev = process.env.NODE_ENV !== 'production';
|
||||||
|
|
@ -30,27 +26,28 @@
|
||||||
...$page.data.metaTagsChild
|
...$page.data.metaTagsChild
|
||||||
}
|
}
|
||||||
|
|
||||||
const flash = getFlash(page, {
|
// const flash = getFlash(page, {
|
||||||
clearAfterMs: 6000
|
// clearAfterMs: 6000
|
||||||
});
|
// });
|
||||||
let flashType;
|
|
||||||
let flashMessage;
|
|
||||||
$: flashType = $flash?.type;
|
|
||||||
$: flashMessage = $flash?.message;
|
|
||||||
|
|
||||||
$: {
|
// let flashType;
|
||||||
if ($navigating) {
|
// let flashMessage;
|
||||||
debounce(() => {
|
// $: flashType = $flash?.type;
|
||||||
boredState.update((n) => ({ ...n, loading: true }));
|
// $: flashMessage = $flash?.message;
|
||||||
}, 250);
|
|
||||||
}
|
|
||||||
if (!$navigating) {
|
|
||||||
boredState.update((n) => ({ ...n, loading: false }));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$: isOpen = $boredState?.dialog?.isOpen;
|
// $: {
|
||||||
$: loading = $boredState?.loading;
|
// if ($navigating) {
|
||||||
|
// debounce(() => {
|
||||||
|
// boredState.update((n) => ({ ...n, loading: true }));
|
||||||
|
// }, 250);
|
||||||
|
// }
|
||||||
|
// if (!$navigating) {
|
||||||
|
// boredState.update((n) => ({ ...n, loading: false }));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $: isOpen = $boredState?.dialog?.isOpen;
|
||||||
|
// $: loading = $boredState?.loading;
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
// set the theme to the user's active theme
|
// set the theme to the user's active theme
|
||||||
|
|
@ -58,21 +55,21 @@
|
||||||
document.querySelector('html')?.setAttribute('data-theme', $theme);
|
document.querySelector('html')?.setAttribute('data-theme', $theme);
|
||||||
});
|
});
|
||||||
|
|
||||||
flash.subscribe(($flash) => {
|
// flash.subscribe(($flash) => {
|
||||||
if (!$flash) return;
|
// if (!$flash) return;
|
||||||
|
|
||||||
if ($flash.type == 'success') {
|
// if ($flash.type == 'success') {
|
||||||
toast.success($flash.message);
|
// toast.success($flash.message);
|
||||||
} else {
|
// } else {
|
||||||
toast.error($flash.message, {
|
// toast.error($flash.message, {
|
||||||
duration: 5000
|
// duration: 5000
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Clearing the flash message could sometimes
|
// // Clearing the flash message could sometimes
|
||||||
// be required here to avoid double-toasting.
|
// // be required here to avoid double-toasting.
|
||||||
flash.set(undefined);
|
// flash.set(undefined);
|
||||||
});
|
// });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if !dev}
|
{#if !dev}
|
||||||
|
|
@ -85,7 +82,7 @@
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if loading}
|
<!-- {#if loading}
|
||||||
<Portal>
|
<Portal>
|
||||||
<div class="loading">
|
<div class="loading">
|
||||||
<Loading />
|
<Loading />
|
||||||
|
|
@ -93,7 +90,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="background" />
|
<div class="background" />
|
||||||
</Portal>
|
</Portal>
|
||||||
{/if}
|
{/if} -->
|
||||||
|
|
||||||
<Toaster />
|
<Toaster />
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { error, json } from '@sveltejs/kit';
|
import { error, json } from '@sveltejs/kit';
|
||||||
|
import prisma from '$lib/prisma';
|
||||||
|
|
||||||
// Search a user's collection
|
// Search a user's collection
|
||||||
export async function GET({ url, locals, params }) {
|
export async function GET({ url, locals, params }) {
|
||||||
|
|
@ -17,7 +18,7 @@ export async function GET({ url, locals, params }) {
|
||||||
throw error(401, { message: 'Unauthorized' });
|
throw error(401, { message: 'Unauthorized' });
|
||||||
}
|
}
|
||||||
|
|
||||||
let collection = await locals.prisma.collection.findUnique({
|
let collection = await prisma.collection.findUnique({
|
||||||
where: {
|
where: {
|
||||||
user_id: locals.user.userId
|
user_id: locals.user.userId
|
||||||
}
|
}
|
||||||
|
|
@ -31,7 +32,7 @@ export async function GET({ url, locals, params }) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const orderBy = { [sort]: order };
|
const orderBy = { [sort]: order };
|
||||||
let collection_items = await locals.prisma.collectionItem.findMany({
|
let collection_items = await prisma.collectionItem.findMany({
|
||||||
where: {
|
where: {
|
||||||
collection_id,
|
collection_id,
|
||||||
AND: [
|
AND: [
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { error, json } from '@sveltejs/kit';
|
import { error, json } from '@sveltejs/kit';
|
||||||
import type { Prisma } from '@prisma/client';
|
import type { Prisma } from '@prisma/client';
|
||||||
import kebabCase from 'just-kebab-case';
|
import prisma from '$lib/prisma';
|
||||||
|
|
||||||
// Search a user's collection
|
// Search a user's collection
|
||||||
export const GET = async ({ url, locals }) => {
|
export const GET = async ({ url, locals }) => {
|
||||||
|
|
@ -17,7 +17,7 @@ export const GET = async ({ url, locals }) => {
|
||||||
try {
|
try {
|
||||||
let games = [];
|
let games = [];
|
||||||
if (exact) {
|
if (exact) {
|
||||||
games = await locals.prisma.game.findFirst({
|
games = await prisma.game.findFirst({
|
||||||
where: {
|
where: {
|
||||||
name: {
|
name: {
|
||||||
equals: q
|
equals: q
|
||||||
|
|
@ -31,7 +31,7 @@ export const GET = async ({ url, locals }) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
games = await locals.prisma.game.findMany({
|
games = await prisma.game.findMany({
|
||||||
orderBy: {
|
orderBy: {
|
||||||
_relevance: {
|
_relevance: {
|
||||||
fields: ['name'],
|
fields: ['name'],
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { error, json } from '@sveltejs/kit';
|
import { error, json } from '@sveltejs/kit';
|
||||||
|
import prisma from '$lib/prisma';
|
||||||
|
|
||||||
// Search a user's collection
|
// Search a user's collection
|
||||||
export async function GET({ url, locals, params }) {
|
export async function GET({ url, locals, params }) {
|
||||||
|
|
@ -17,7 +18,7 @@ export async function GET({ url, locals, params }) {
|
||||||
throw error(401, { message: 'Unauthorized' });
|
throw error(401, { message: 'Unauthorized' });
|
||||||
}
|
}
|
||||||
|
|
||||||
let collection = await locals.prisma.collection.findUnique({
|
let collection = await prisma.collection.findUnique({
|
||||||
where: {
|
where: {
|
||||||
user_id: locals.user.userId
|
user_id: locals.user.userId
|
||||||
}
|
}
|
||||||
|
|
@ -31,7 +32,7 @@ export async function GET({ url, locals, params }) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const orderBy = { [sort]: order };
|
const orderBy = { [sort]: order };
|
||||||
let collection_items = await locals.prisma.collectionItem.findMany({
|
let collection_items = await prisma.collectionItem.findMany({
|
||||||
where: {
|
where: {
|
||||||
collection_id,
|
collection_id,
|
||||||
AND: [
|
AND: [
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,10 @@ const config = {
|
||||||
},
|
},
|
||||||
shadcn: {
|
shadcn: {
|
||||||
componentPath: './src/lib/components/ui'
|
componentPath: './src/lib/components/ui'
|
||||||
}
|
},
|
||||||
|
compilerOptions: {
|
||||||
|
enableSourcemap: true,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,20 @@
|
||||||
import { sentrySvelteKit } from "@sentry/sveltekit";
|
import { sentrySvelteKit } from "@sentry/sveltekit";
|
||||||
import { sveltekit } from '@sveltejs/kit/vite';
|
import { sveltekit } from '@sveltejs/kit/vite';
|
||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import fs from 'fs';
|
// import fs from 'fs';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
sentrySvelteKit({
|
sentrySvelteKit({
|
||||||
sourceMapsUploadOptions: {
|
sourceMapsUploadOptions: {
|
||||||
org: process.env.SENTRY_ORG,
|
org: process.env.SENTRY_ORG,
|
||||||
project: process.env.SENTRY_PROJECT,
|
project: process.env.SENTRY_PROJECT,
|
||||||
authToken: process.env.SENTRY_AUTH_TOKEN,
|
authToken: process.env.SENTRY_AUTH_TOKEN,
|
||||||
cleanArtifacts: true,
|
cleanArtifacts: true,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
sveltekit(), rawFonts(['.ttf'])
|
sveltekit()
|
||||||
|
// , rawFonts(['.ttf'])
|
||||||
],
|
],
|
||||||
test: {
|
test: {
|
||||||
include: ['src/**/*.{test,spec}.{js,ts}']
|
include: ['src/**/*.{test,spec}.{js,ts}']
|
||||||
|
|
@ -43,14 +44,14 @@ export default defineConfig({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function rawFonts(ext) {
|
// function rawFonts(ext) {
|
||||||
return {
|
// return {
|
||||||
name: 'vite-plugin-raw-fonts',
|
// name: 'vite-plugin-raw-fonts',
|
||||||
transform(code, id) {
|
// transform(code, id) {
|
||||||
if (ext.some((e) => id.endsWith(e))) {
|
// if (ext.some((e) => id.endsWith(e))) {
|
||||||
const buffer = fs.readFileSync(id);
|
// const buffer = fs.readFileSync(id);
|
||||||
return { code: `export default ${JSON.stringify(buffer)}`, map: null };
|
// return { code: `export default ${JSON.stringify(buffer)}`, map: null };
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
Loading…
Reference in a new issue