mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
Change prisma import to not have .js
This commit is contained in:
parent
8e557498e3
commit
fa138fe8a3
14 changed files with 46 additions and 31 deletions
|
|
@ -1,10 +1,9 @@
|
|||
import prisma from "$lib/prisma";
|
||||
import type { GameType } from "$lib/types";
|
||||
import type { Game } from "@prisma/client";
|
||||
import type { BggThingDto } from "boardgamegeekclient/dist/esm/dto";
|
||||
import type { BggLinkDto } from "boardgamegeekclient/dist/esm/dto/concrete/subdto";
|
||||
import kebabCase from "just-kebab-case";
|
||||
import { mapAPIGameToBoredGame } from "./gameMapper";
|
||||
import type { Game } from '@prisma/client';
|
||||
import kebabCase from 'just-kebab-case';
|
||||
import type { BggLinkDto } from 'boardgamegeekclient/dist/esm/dto/concrete/subdto';
|
||||
import prisma from '$lib/prisma';
|
||||
import type { GameType } from '$lib/types';
|
||||
import { mapAPIGameToBoredGame } from './gameMapper';
|
||||
|
||||
export async function createArtist(externalArtist: BggLinkDto) {
|
||||
try {
|
||||
|
|
@ -204,7 +203,12 @@ export async function createMechanic(externalMechanic: BggLinkDto) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function createExpansion(game: Game, externalExpansion: BggLinkDto, gameIsExpansion: boolean, eventFetch: Function) {
|
||||
export async function createExpansion(
|
||||
game: Game,
|
||||
externalExpansion: BggLinkDto,
|
||||
gameIsExpansion: boolean,
|
||||
eventFetch: Function
|
||||
) {
|
||||
try {
|
||||
let dbExpansionGame = await prisma.game.findUnique({
|
||||
where: {
|
||||
|
|
@ -222,7 +226,9 @@ export async function createExpansion(game: Game, externalExpansion: BggLinkDto,
|
|||
let boredGame = mapAPIGameToBoredGame(externalGame);
|
||||
dbExpansionGame = await createOrUpdateGameMinimal(boredGame);
|
||||
} else {
|
||||
throw new Error(`${gameIsExpansion ? 'Base game' : 'Expansion game'} not found and failed to create.`);
|
||||
throw new Error(
|
||||
`${gameIsExpansion ? 'Base game' : 'Expansion game'} not found and failed to create.`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -230,7 +236,10 @@ export async function createExpansion(game: Game, externalExpansion: BggLinkDto,
|
|||
let baseGameId;
|
||||
let gameId;
|
||||
if (gameIsExpansion) {
|
||||
console.log('External expansion is expansion. Looking for base game', JSON.stringify(game, null, 2));
|
||||
console.log(
|
||||
'External expansion is expansion. Looking for base game',
|
||||
JSON.stringify(game, null, 2)
|
||||
);
|
||||
dbExpansion = await prisma.expansion.findFirst({
|
||||
where: {
|
||||
game_id: dbExpansionGame.id
|
||||
|
|
@ -244,7 +253,10 @@ export async function createExpansion(game: Game, externalExpansion: BggLinkDto,
|
|||
baseGameId = game.id;
|
||||
gameId = dbExpansionGame.id;
|
||||
} else {
|
||||
console.log('External Expansion is base game. Looking for expansion', JSON.stringify(game, null, 2));
|
||||
console.log(
|
||||
'External Expansion is base game. Looking for expansion',
|
||||
JSON.stringify(game, null, 2)
|
||||
);
|
||||
dbExpansion = await prisma.expansion.findFirst({
|
||||
where: {
|
||||
base_game_id: dbExpansionGame.id
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { error, fail, redirect } from '@sveltejs/kit';
|
||||
import { setError, superValidate } from 'sveltekit-superforms/server';
|
||||
import type { PageServerLoad } from '../../$types.js';
|
||||
import prisma from '$lib/prisma.js';
|
||||
import prisma from '$lib/prisma';
|
||||
import { modifyListGameSchema, type ListGame } from '$lib/config/zod-schemas.js';
|
||||
import type { CollectionItemWithGame } from '$lib/types.js';
|
||||
import { search_schema } from '$lib/zodValidation.js';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import prisma from '$lib/prisma.js';
|
||||
import prisma from '$lib/prisma';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
|
||||
export async function load({ params, locals }) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { fail, redirect } from '@sveltejs/kit';
|
||||
import { superValidate } from 'sveltekit-superforms/server';
|
||||
import prisma from '$lib/prisma.js';
|
||||
import prisma from '$lib/prisma';
|
||||
import { list_game_request_schema } from '$lib/zodValidation';
|
||||
|
||||
export async function load({ params, locals }) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import { message, setError, superValidate } from 'sveltekit-superforms/server';
|
|||
import { userSchema } from '$lib/config/zod-schemas';
|
||||
import { auth } from '$lib/server/lucia.js';
|
||||
import { LuciaError } from 'lucia';
|
||||
// import prisma from '$lib/prisma.js';
|
||||
|
||||
const profileSchema = userSchema.pick({
|
||||
firstName: true,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { error, redirect } from '@sveltejs/kit';
|
||||
import { superValidate } from 'sveltekit-superforms/server';
|
||||
import prisma from '$lib/prisma.js';
|
||||
import { list_game_request_schema } from '$lib/zodValidation';
|
||||
import prisma from '$lib/prisma';
|
||||
import { modifyListGameSchema } from '$lib/config/zod-schemas.js';
|
||||
|
||||
export async function load({ params, locals }) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { error } from '@sveltejs/kit';
|
||||
import prisma from '$lib/prisma.js';
|
||||
import type { GameType } from '$lib/types.js';
|
||||
import prisma from '$lib/prisma';
|
||||
import {
|
||||
createArtist,
|
||||
createCategory,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import { error } from '@sveltejs/kit';
|
||||
import { superValidate } from 'sveltekit-superforms/server';
|
||||
import kebabCase from 'just-kebab-case';
|
||||
import { BOARD_GAME_ATLAS_CLIENT_ID } from '$env/static/private';
|
||||
import prisma from '$lib/prisma.js';
|
||||
import type { GameType, SearchQuery } from '$lib/types';
|
||||
import { mapAPIGameToBoredGame } from '$lib/utils/gameMapper.js';
|
||||
import { search_schema } from '$lib/zodValidation';
|
||||
|
|
@ -141,6 +139,17 @@ export const load: PageServerLoad = async ({ fetch, url }) => {
|
|||
|
||||
// fields: ('id,name,min_age,min_players,max_players,thumb_url,min_playtime,max_playtime,min_age,description');
|
||||
try {
|
||||
if (form.data?.q === '') {
|
||||
return {
|
||||
form,
|
||||
searchData: {
|
||||
totalCount: 0,
|
||||
games: [],
|
||||
wishlists: []
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (form.data?.minAge) {
|
||||
if (form.data?.exactMinAge) {
|
||||
queryParams.min_age = form.data?.minAge;
|
||||
|
|
@ -175,7 +184,8 @@ export const load: PageServerLoad = async ({ fetch, url }) => {
|
|||
return {
|
||||
form,
|
||||
// modifyListForm,
|
||||
searchData
|
||||
searchData,
|
||||
wishlists: []
|
||||
};
|
||||
} catch (e) {
|
||||
console.log(`Error searching board games ${e}`);
|
||||
|
|
@ -196,7 +206,6 @@ export const actions = {
|
|||
const queryParams: SearchQuery = {
|
||||
order_by: 'rank',
|
||||
ascending: false,
|
||||
client_id: BOARD_GAME_ATLAS_CLIENT_ID,
|
||||
random: true,
|
||||
fields:
|
||||
'id,name,min_age,min_players,max_players,thumb_url,min_playtime,max_playtime,min_age,description'
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { fail } from '@sveltejs/kit';
|
|||
import { setError, superValidate } from 'sveltekit-superforms/server';
|
||||
import { redirect } from 'sveltekit-flash-message/server';
|
||||
import { auth } from '$lib/server/lucia';
|
||||
import prisma from '$lib/prisma.js';
|
||||
import prisma from '$lib/prisma';
|
||||
import { userSchema } from '$lib/config/zod-schemas';
|
||||
|
||||
const signInSchema = userSchema.pick({
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { LuciaError } from 'lucia';
|
|||
import { auth } from '$lib/server/lucia';
|
||||
import { userSchema } from '$lib/config/zod-schemas';
|
||||
import { add_user_to_role } from '$server/roles';
|
||||
import prisma from '$lib/prisma.js';
|
||||
import prisma from '$lib/prisma';
|
||||
import { Schema } from 'zod';
|
||||
import type { Message } from '$lib/types.js';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { error, json } from '@sveltejs/kit';
|
||||
import prisma from '$lib/prisma.js';
|
||||
import prisma from '$lib/prisma';
|
||||
import type { CollectionItemWithGame } from '$lib/types.js';
|
||||
|
||||
// Search a user's collection
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { error, json } from '@sveltejs/kit';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import prisma from '$lib/prisma.js';
|
||||
import prisma from '$lib/prisma';
|
||||
|
||||
// Search a user's collection
|
||||
export const GET = async ({ url }) => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { error, json } from '@sveltejs/kit';
|
||||
import prisma from '$lib/prisma.js';
|
||||
import prisma from '$lib/prisma';
|
||||
import type { CollectionItemWithGame } from '$lib/types.js';
|
||||
|
||||
// Search a user's collection
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { invalid, type RequestEvent } from '@sveltejs/kit';
|
||||
import { BOARD_GAME_ATLAS_CLIENT_ID } from '$env/static/private';
|
||||
import type { GameType, SearchQuery } from '$lib/types';
|
||||
import { mapAPIGameToBoredGame } from '$lib/utils/gameMapper';
|
||||
|
||||
|
|
@ -18,8 +17,6 @@ export const Games: Actions = {
|
|||
ascending: false,
|
||||
limit: 10,
|
||||
skip: 0,
|
||||
client_id: BOARD_GAME_ATLAS_CLIENT_ID,
|
||||
fuzzy_match: true,
|
||||
name: ''
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue