Switched to local prismaclient
This commit is contained in:
parent
de02f94f6a
commit
1bd327ea1a
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -55,6 +55,7 @@
|
||||
},
|
||||
"importSorter.generalConfiguration.sortOnBeforeSave": true,
|
||||
"cSpell.words": [
|
||||
"prismaclient",
|
||||
"vars"
|
||||
]
|
||||
}
|
||||
|
||||
1140
package-lock.json
generated
1140
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -42,7 +42,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/eslintrc": "^3",
|
||||
"@types/bcryptjs": "^5.0.2",
|
||||
"@types/express": "^5.0.1",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { PrismaClient } from "@prismaclient";
|
||||
|
||||
const usingPrisma = false;
|
||||
let prisma: PrismaClient;
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
import { parse } from "csv-parse/sync";
|
||||
import fs from "fs/promises";
|
||||
import { NextResponse } from "next/server";
|
||||
import path from "path";
|
||||
|
||||
import { PrismaClient } from "@prismaclient";
|
||||
|
||||
// CSV location
|
||||
const csvFilePath = path.resolve(process.cwd(), "public/artefacts.csv");
|
||||
@ -39,9 +40,7 @@ export async function POST() {
|
||||
warehouseArea: row.WarehouseArea,
|
||||
earthquakeId: parseInt(row.EarthquakeId, 10),
|
||||
required: stringToBool(row.Required, true), // default TRUE
|
||||
shopPrice: row.ShopPrice && row.ShopPrice !== ""
|
||||
? parseFloat(row.ShopPrice)
|
||||
: null,
|
||||
shopPrice: row.ShopPrice && row.ShopPrice !== "" ? parseFloat(row.ShopPrice) : null,
|
||||
pickedUp: stringToBool(row.PickedUp, false), // default FALSE
|
||||
creatorId: null,
|
||||
purchasedById: null,
|
||||
@ -59,10 +58,7 @@ export async function POST() {
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
return NextResponse.json(
|
||||
{ success: false, error: error.message },
|
||||
{ status: 500 }
|
||||
);
|
||||
return NextResponse.json({ success: false, error: error.message }, { status: 500 });
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
import { parse } from "csv-parse/sync";
|
||||
import fs from "fs/promises";
|
||||
import { NextResponse } from "next/server";
|
||||
import path from "path";
|
||||
|
||||
import { PrismaClient } from "@prismaclient";
|
||||
|
||||
// Path to your earthquakes.csv
|
||||
const csvFilePath = path.resolve(process.cwd(), "public/earthquakes.csv");
|
||||
@ -26,10 +27,10 @@ export async function POST() {
|
||||
// 2. Parse the CSV
|
||||
const records: CsvRow[] = parse(fileContent, {
|
||||
columns: true,
|
||||
skip_empty_lines: true
|
||||
skip_empty_lines: true,
|
||||
});
|
||||
// 3. Transform to fit Earthquake model
|
||||
const earthquakes = records.map(row => ({
|
||||
const earthquakes = records.map((row) => ({
|
||||
date: new Date(row.Date),
|
||||
code: row.Code,
|
||||
magnitude: parseFloat(row.Magnitude),
|
||||
@ -38,7 +39,7 @@ export async function POST() {
|
||||
longitude: parseFloat(row.Longitude),
|
||||
location: row.Location,
|
||||
depth: row.Depth, // store as received
|
||||
creatorId: null
|
||||
creatorId: null,
|
||||
}));
|
||||
// 4. Bulk create earthquakes in database:
|
||||
await prisma.earthquake.createMany({
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
import { parse } from "csv-parse/sync";
|
||||
import fs from "fs/promises";
|
||||
import { NextResponse } from "next/server";
|
||||
import path from "path";
|
||||
|
||||
import { PrismaClient } from "@prismaclient";
|
||||
|
||||
// CSV location (update filename as needed)
|
||||
const csvFilePath = path.resolve(process.cwd(), "public/observatories.csv");
|
||||
@ -41,13 +42,9 @@ export async function POST() {
|
||||
location: row.Location,
|
||||
latitude: row.Latitude,
|
||||
longitude: row.Longitude,
|
||||
dateEstablished: row.DateEstablished
|
||||
? parseInt(row.DateEstablished, 10)
|
||||
: null,
|
||||
dateEstablished: row.DateEstablished ? parseInt(row.DateEstablished, 10) : null,
|
||||
functional: stringToBool(row.Functional),
|
||||
seismicSensorOnline: row.SeismicSensorOnline
|
||||
? stringToBool(row.SeismicSensorOnline)
|
||||
: true, // default true per schema
|
||||
seismicSensorOnline: row.SeismicSensorOnline ? stringToBool(row.SeismicSensorOnline) : true, // default true per schema
|
||||
creatorId: null,
|
||||
}));
|
||||
|
||||
@ -63,10 +60,7 @@ export async function POST() {
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
return NextResponse.json(
|
||||
{ success: false, error: error.message },
|
||||
{ status: 500 }
|
||||
);
|
||||
return NextResponse.json({ success: false, error: error.message }, { status: 500 });
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
import { parse } from "csv-parse/sync";
|
||||
import fs from "fs/promises";
|
||||
import { NextResponse } from "next/server";
|
||||
import path from "path";
|
||||
|
||||
import { PrismaClient } from "@prismaclient";
|
||||
|
||||
const csvFilePath = path.resolve(process.cwd(), "public/requests.csv");
|
||||
const prisma = new PrismaClient();
|
||||
@ -17,13 +18,7 @@ type CsvRow = {
|
||||
};
|
||||
|
||||
const validRequestTypes: RequestType[] = ["NEW_USER", "CHANGE_LEVEL", "DELETE"];
|
||||
const validOutcomes: RequestOutcome[] = [
|
||||
"FULFILLED",
|
||||
"REJECTED",
|
||||
"IN_PROGRESS",
|
||||
"CANCELLED",
|
||||
"OTHER",
|
||||
];
|
||||
const validOutcomes: RequestOutcome[] = ["FULFILLED", "REJECTED", "IN_PROGRESS", "CANCELLED", "OTHER"];
|
||||
|
||||
function normalizeRequestType(type: string | undefined): RequestType {
|
||||
if (!type) return "NEW_USER";
|
||||
@ -45,13 +40,13 @@ export async function POST() {
|
||||
skip_empty_lines: true,
|
||||
});
|
||||
|
||||
const requests = records.map(row => ({
|
||||
const requests = records.map((row) => ({
|
||||
requestType: normalizeRequestType(row.RequestType),
|
||||
requestingUserId: parseInt(row.RequestingUserId, 10),
|
||||
outcome: normalizeOutcome(row.Outcome),
|
||||
}));
|
||||
|
||||
const filteredRequests = requests.filter(r => !isNaN(r.requestingUserId));
|
||||
const filteredRequests = requests.filter((r) => !isNaN(r.requestingUserId));
|
||||
|
||||
await prisma.request.createMany({
|
||||
data: filteredRequests,
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
import { parse } from "csv-parse/sync";
|
||||
import fs from "fs/promises";
|
||||
import { NextResponse } from "next/server";
|
||||
import path from "path";
|
||||
|
||||
import { PrismaClient } from "@prismaclient";
|
||||
|
||||
// Path to CSV file
|
||||
const csvFilePath = path.resolve(process.cwd(), "public/scientists.csv");
|
||||
@ -34,7 +35,7 @@ export async function POST() {
|
||||
});
|
||||
|
||||
// 3. Transform each record for Prisma
|
||||
const scientists = records.map(row => ({
|
||||
const scientists = records.map((row) => ({
|
||||
name: row.Name,
|
||||
level: normalizeLevel(row.Level),
|
||||
userId: parseInt(row.UserId, 10),
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
import { parse } from "csv-parse/sync";
|
||||
import fs from "fs/promises";
|
||||
import { NextResponse } from "next/server";
|
||||
import path from "path";
|
||||
|
||||
import { PrismaClient } from "@prismaclient";
|
||||
|
||||
// Path to users.csv - adjust as needed
|
||||
const csvFilePath = path.resolve(process.cwd(), "public/users.csv");
|
||||
@ -34,7 +35,7 @@ export async function POST() {
|
||||
});
|
||||
|
||||
// 3. Transform each CSV row to User model format
|
||||
const users = records.map(row => ({
|
||||
const users = records.map((row) => ({
|
||||
name: row.Name,
|
||||
email: row.Email,
|
||||
passwordHash: row.PasswordHash,
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import bcryptjs from 'bcryptjs';
|
||||
import { SignJWT } from 'jose';
|
||||
import { NextResponse } from 'next/server';
|
||||
import bcryptjs from "bcryptjs";
|
||||
import { SignJWT } from "jose";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { env } from '@utils/env';
|
||||
import { PrismaClient } from "@prismaclient";
|
||||
import { env } from "@utils/env";
|
||||
|
||||
import { findUserByEmail, readUserCsv, User } from '../functions/csvReadWrite';
|
||||
import { findUserByEmail, readUserCsv, User } from "../functions/csvReadWrite";
|
||||
|
||||
const usingPrisma = false;
|
||||
let prisma: PrismaClient;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { PrismaClient } from "@prismaclient";
|
||||
|
||||
const usingPrisma = false;
|
||||
let prisma: PrismaClient;
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
import bcryptjs from 'bcryptjs';
|
||||
import { SignJWT } from 'jose';
|
||||
import { NextResponse } from 'next/server';
|
||||
import bcryptjs from "bcryptjs";
|
||||
import { SignJWT } from "jose";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { env } from '@utils/env';
|
||||
import { PrismaClient } from "@prismaclient";
|
||||
import { env } from "@utils/env";
|
||||
|
||||
import {
|
||||
findUserByEmail, passwordStrengthCheck, readUserCsv, User, writeUserCsv
|
||||
} from '../functions/csvReadWrite';
|
||||
import { findUserByEmail, passwordStrengthCheck, readUserCsv, User, writeUserCsv } from "../functions/csvReadWrite";
|
||||
|
||||
const usingPrisma = false;
|
||||
let prisma: PrismaClient;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { env } from "@utils/env";
|
||||
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { PrismaClient } from "@prismaclient";
|
||||
import { env } from "@utils/env";
|
||||
import { verifyJwt } from "@utils/verifyJwt";
|
||||
|
||||
const usingPrisma = false;
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
"use client";
|
||||
import { useState, useMemo } from "react";
|
||||
import { FaCalendarPlus, FaWarehouse, FaCartShopping } from "react-icons/fa6";
|
||||
import { IoFilter, IoFilterCircleOutline, IoFilterOutline, IoToday } from "react-icons/io5";
|
||||
import { Dispatch, SetStateAction, useMemo, useState } from "react";
|
||||
import { FaTimes } from "react-icons/fa";
|
||||
import { SetStateAction, Dispatch } from "react";
|
||||
// import type { Artefact } from "@prisma/client";
|
||||
import { Artefact } from "@appTypes/Prisma";
|
||||
import { FaCalendarPlus, FaCartShopping, FaWarehouse } from "react-icons/fa6";
|
||||
import { IoFilter, IoFilterCircleOutline, IoFilterOutline, IoToday } from "react-icons/io5";
|
||||
|
||||
// import { Artefact } from "@appTypes/Prisma";
|
||||
|
||||
import type { Artefact } from "@prismaclient";
|
||||
|
||||
// Warehouse Artefacts Data
|
||||
const warehouseArtefacts: Artefact[] = [
|
||||
@ -14,7 +15,7 @@ const warehouseArtefacts: Artefact[] = [
|
||||
name: "Solidified Lava Chunk",
|
||||
description: "A chunk of solidified lava from the 2023 Iceland eruption.",
|
||||
location: "Reykjanes, Iceland",
|
||||
earthquakeId: "EQ2023ICL",
|
||||
code: "EQ2023ICL",
|
||||
isRequired: true,
|
||||
isSold: false,
|
||||
isCollected: false,
|
||||
@ -25,7 +26,7 @@ const warehouseArtefacts: Artefact[] = [
|
||||
name: "Tephra Sample",
|
||||
description: "Foreign debris from the 2022 Tonga volcanic eruption.",
|
||||
location: "Tonga",
|
||||
earthquakeId: "EQ2022TGA",
|
||||
code: "EQ2022TGA",
|
||||
isRequired: false,
|
||||
isSold: true,
|
||||
isCollected: true,
|
||||
@ -36,7 +37,7 @@ const warehouseArtefacts: Artefact[] = [
|
||||
name: "Ash Sample",
|
||||
description: "Volcanic ash from the 2021 La Palma eruption.",
|
||||
location: "La Palma, Spain",
|
||||
earthquakeId: "EQ2021LPA",
|
||||
code: "EQ2021LPA",
|
||||
isRequired: false,
|
||||
isSold: false,
|
||||
isCollected: false,
|
||||
@ -47,7 +48,7 @@ const warehouseArtefacts: Artefact[] = [
|
||||
name: "Ground Soil",
|
||||
description: "Soil sample from the 2020 Croatia earthquake site.",
|
||||
location: "Zagreb, Croatia",
|
||||
earthquakeId: "EQ2020CRO",
|
||||
code: "EQ2020CRO",
|
||||
isRequired: true,
|
||||
isSold: false,
|
||||
isCollected: false,
|
||||
@ -58,7 +59,7 @@ const warehouseArtefacts: Artefact[] = [
|
||||
name: "Basalt Fragment",
|
||||
description: "Basalt rock from the 2019 New Zealand eruption.",
|
||||
location: "White Island, New Zealand",
|
||||
earthquakeId: "EQ2019NZL",
|
||||
code: "EQ2019NZL",
|
||||
isRequired: false,
|
||||
isSold: true,
|
||||
isCollected: false,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { PrismaClient } from "@prismaclient";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
"@utils/*": ["./src/utils/*"],
|
||||
"@appTypes/*": ["./src/types/*"],
|
||||
"@zod/*": ["./src/zod/*"],
|
||||
"@prismaclient": ["./src/generated/prisma/client"],
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user