Merge branch 'master' of ssh://stash.dyson.global.corp:7999/~thowitz/tremor-tracker
This commit is contained in:
commit
06403d254f
1839
package-lock.json
generated
1839
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,6 @@
|
|||||||
"@types/jsonwebtoken": "^9.0.9",
|
"@types/jsonwebtoken": "^9.0.9",
|
||||||
"@types/mapbox-gl": "^3.4.1",
|
"@types/mapbox-gl": "^3.4.1",
|
||||||
"axios": "^1.9.0",
|
"axios": "^1.9.0",
|
||||||
"bcrypt": "^5.1.1",
|
|
||||||
"bcryptjs": "^3.0.2",
|
"bcryptjs": "^3.0.2",
|
||||||
"body-parser": "^2.2.0",
|
"body-parser": "^2.2.0",
|
||||||
"csv-parser": "^3.2.0",
|
"csv-parser": "^3.2.0",
|
||||||
@ -29,11 +28,11 @@
|
|||||||
"leaflet": "^1.9.4",
|
"leaflet": "^1.9.4",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"mapbox-gl": "^3.10.0",
|
"mapbox-gl": "^3.10.0",
|
||||||
"next": "15.1.7",
|
"next": "^15.1.7",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
"prisma": "^6.4.1",
|
"prisma": "^6.4.1",
|
||||||
"react": "^19.0.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.0.0",
|
"react-dom": "^19.1.0",
|
||||||
"react-icons": "^5.5.0",
|
"react-icons": "^5.5.0",
|
||||||
"react-leaflet": "^5.0.0",
|
"react-leaflet": "^5.0.0",
|
||||||
"react-node": "^1.0.2",
|
"react-node": "^1.0.2",
|
||||||
@ -42,7 +41,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/eslintrc": "^3",
|
"@eslint/eslintrc": "^3",
|
||||||
"@types/bcrypt": "^5.0.2",
|
"@types/bcryptjs": "^5.0.2",
|
||||||
"@types/express": "^5.0.1",
|
"@types/express": "^5.0.1",
|
||||||
"@types/node": "^20",
|
"@types/node": "^20",
|
||||||
"@types/react": "^19",
|
"@types/react": "^19",
|
||||||
|
|||||||
85
prisma/schema.prisma
Normal file
85
prisma/schema.prisma
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
// Datasource configuration
|
||||||
|
datasource db {
|
||||||
|
provider = "sqlserver"
|
||||||
|
url = env("DATABASE_URL")
|
||||||
|
}
|
||||||
|
|
||||||
|
// User model
|
||||||
|
model User {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
name String
|
||||||
|
email String @unique
|
||||||
|
passwordHash String
|
||||||
|
role String @default("GUEST") @db.VarChar(10) // ADMIN, SCIENTIST, GUEST
|
||||||
|
scientist Scientist? @relation
|
||||||
|
purchasedArtefacts Artefact[] @relation("UserPurchasedArtefacts")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scientist model
|
||||||
|
model Scientist {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
name String
|
||||||
|
level String @db.VarChar(10) // JUNIOR, SENIOR
|
||||||
|
user User @relation(fields: [userId], references: [id])
|
||||||
|
userId Int @unique
|
||||||
|
superior Scientist? @relation("SuperiorRelation", fields: [superiorId], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||||
|
superiorId Int?
|
||||||
|
subordinates Scientist[] @relation("SuperiorRelation")
|
||||||
|
earthquakes Earthquake[] @relation("ScientistEarthquakeCreator")
|
||||||
|
observatories Observatory[] @relation("ScientistObservatoryCreator")
|
||||||
|
artefacts Artefact[] @relation("ScientistArtefactCreator")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Earthquake model
|
||||||
|
model Earthquake {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
date DateTime
|
||||||
|
location String
|
||||||
|
latitude String
|
||||||
|
longitude String
|
||||||
|
magnitude Float
|
||||||
|
depth Float
|
||||||
|
creatorId Int?
|
||||||
|
creator Scientist? @relation("ScientistEarthquakeCreator", fields: [creatorId], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||||
|
artefacts Artefact[]
|
||||||
|
observatories Observatory[] @relation("EarthquakeObservatory")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Observatory model
|
||||||
|
model Observatory {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
name String
|
||||||
|
location String
|
||||||
|
longitude String
|
||||||
|
latitude String
|
||||||
|
dateEstablished Int?
|
||||||
|
functional Boolean
|
||||||
|
seismicSensorOnline Boolean @default(true)
|
||||||
|
creatorId Int?
|
||||||
|
creator Scientist? @relation("ScientistObservatoryCreator", fields: [creatorId], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||||
|
earthquakes Earthquake[] @relation("EarthquakeObservatory")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Artefact model
|
||||||
|
model Artefact {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
type String @db.VarChar(50) // Lava, Tephra, Ash, Soil
|
||||||
|
warehouseArea String // Examples: "ZoneA-Shelf1", "ZoneB-Rack2", "ZoneC-Bin3"
|
||||||
|
earthquakeId Int
|
||||||
|
earthquake Earthquake @relation(fields: [earthquakeId], references: [id])
|
||||||
|
creatorId Int?
|
||||||
|
creator Scientist? @relation("ScientistArtefactCreator", fields: [creatorId], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||||
|
required Boolean @default(true)
|
||||||
|
shopPrice Float? // In Euros
|
||||||
|
purchasedById Int?
|
||||||
|
purchasedBy User? @relation("UserPurchasedArtefacts", fields: [purchasedById], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||||
|
pickedUp Boolean @default(false)
|
||||||
|
}
|
||||||
1573
public/earthquakes.csv
Normal file
1573
public/earthquakes.csv
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
import bcrypt from 'bcrypt';
|
import bcryptjs from 'bcryptjs';
|
||||||
import { SignJWT } from 'jose';
|
import { SignJWT } from 'jose';
|
||||||
import { NextResponse } from 'next/server';
|
import { NextResponse } from 'next/server';
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import bcrypt from "bcrypt";
|
import bcryptjs from "bcryptjs";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
import { PrismaClient } from "@prisma/client";
|
import { PrismaClient } from "@prisma/client";
|
||||||
@ -56,7 +56,7 @@ export async function POST(req: Request) {
|
|||||||
return NextResponse.json({ message: "Password check script failure" }, { status: 500 });
|
return NextResponse.json({ message: "Password check script failure" }, { status: 500 });
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
const passwordHash = await bcrypt.hash(password, 10);
|
const passwordHash = await bcryptjs.hash(password, 10);
|
||||||
if (usingPrisma) {
|
if (usingPrisma) {
|
||||||
// todo add sending back newUser
|
// todo add sending back newUser
|
||||||
const newUser = await prisma.user.create({
|
const newUser = await prisma.user.create({
|
||||||
|
|||||||
@ -1,85 +0,0 @@
|
|||||||
// Datasource configuration
|
|
||||||
datasource db {
|
|
||||||
provider = "sqlserver"
|
|
||||||
url = env("DATABASE_URL")
|
|
||||||
}
|
|
||||||
|
|
||||||
// User model
|
|
||||||
model User {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
name String
|
|
||||||
email String @unique
|
|
||||||
passwordHash String
|
|
||||||
role String @default("GUEST") @db.VarChar(10) // ADMIN, SCIENTIST, GUEST
|
|
||||||
scientist Scientist? @relation
|
|
||||||
purchasedArtifacts Artifact[] @relation("UserPurchasedArtifacts")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scientist model
|
|
||||||
model Scientist {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
name String
|
|
||||||
level String @db.VarChar(10) // JUNIOR, SENIOR
|
|
||||||
user User @relation(fields: [userId], references: [id])
|
|
||||||
userId Int @unique
|
|
||||||
superior Scientist? @relation("SuperiorRelation", fields: [superiorId], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
|
||||||
superiorId Int?
|
|
||||||
subordinates Scientist[] @relation("SuperiorRelation")
|
|
||||||
earthquakes Earthquake[] @relation("ScientistEarthquakeCreator")
|
|
||||||
observatories Observatory[] @relation("ScientistObservatoryCreator")
|
|
||||||
artifacts Artifact[] @relation("ScientistArtifactCreator")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Earthquake model
|
|
||||||
model Earthquake {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
updatedAt DateTime @updatedAt
|
|
||||||
date DateTime
|
|
||||||
locaiton String
|
|
||||||
latitude String
|
|
||||||
longitude String
|
|
||||||
magnitude Float
|
|
||||||
depth Float
|
|
||||||
creatorId Int?
|
|
||||||
creator Scientist? @relation("ScientistEarthquakeCreator", fields: [creatorId], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
|
||||||
artifacts Artifact[]
|
|
||||||
observatories Observatory[] @relation("EarthquakeObservatory")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Observatory model
|
|
||||||
model Observatory {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
updatedAt DateTime @updatedAt
|
|
||||||
name String
|
|
||||||
location String
|
|
||||||
longitude String
|
|
||||||
latitude String
|
|
||||||
dateEstablished Int?
|
|
||||||
functional Boolean
|
|
||||||
seismicSensorOnline Boolean @default(true)
|
|
||||||
creatorId Int?
|
|
||||||
creator Scientist? @relation("ScientistObservatoryCreator", fields: [creatorId], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
|
||||||
earthquakes Earthquake[] @relation("EarthquakeObservatory")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Artifact model
|
|
||||||
model Artifact {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
updatedAt DateTime @updatedAt
|
|
||||||
type String @db.VarChar(50) // Lava, Tephra, Ash, Soil
|
|
||||||
warehouseArea String // Examples: "ZoneA-Shelf1", "ZoneB-Rack2", "ZoneC-Bin3"
|
|
||||||
earthquakeId Int
|
|
||||||
earthquake Earthquake @relation(fields: [earthquakeId], references: [id])
|
|
||||||
creatorId Int?
|
|
||||||
creator Scientist? @relation("ScientistArtifactCreator", fields: [creatorId], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
|
||||||
required Boolean @default(true)
|
|
||||||
shopPrice Float? // In Euros
|
|
||||||
purchasedById Int?
|
|
||||||
purchasedBy User? @relation("UserPurchasedArtifacts", fields: [purchasedById], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
|
||||||
pickedUp Boolean @default(false)
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user