Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"dotenv": "^16.4.5",
"dotenv-cli": "^7.4.2",
"express": "^4.18.2",
"express-async-errors": "^3.1.1",
"firebase-admin": "^12.2.0",
"sharp": "^0.33.5",
"socket.io": "^4.7.5",
Expand Down Expand Up @@ -714,6 +715,8 @@

"express": ["[email protected]", "", { "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", "body-parser": "1.20.3", "content-disposition": "0.5.4", "content-type": "~1.0.4", "cookie": "0.7.1", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "etag": "~1.8.1", "finalhandler": "1.3.1", "fresh": "0.5.2", "http-errors": "2.0.0", "merge-descriptors": "1.0.3", "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", "path-to-regexp": "0.1.12", "proxy-addr": "~2.0.7", "qs": "6.13.0", "range-parser": "~1.2.1", "safe-buffer": "5.2.1", "send": "0.19.0", "serve-static": "1.16.2", "setprototypeof": "1.2.0", "statuses": "2.0.1", "type-is": "~1.6.18", "utils-merge": "1.0.1", "vary": "~1.1.2" } }, "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA=="],

"express-async-errors": ["[email protected]", "", { "peerDependencies": { "express": "^4.16.2" } }, "sha512-h6aK1da4tpqWSbyCa3FxB/V6Ehd4EEB15zyQq9qe75OZBp0krinNKuH4rAY+S/U/2I36vdLAUFSjQJ+TFmODng=="],

"extend": ["[email protected]", "", {}, "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="],

"farmhash-modern": ["[email protected]", "", {}, "sha512-6ypT4XfgqJk/F3Yuv4SX26I3doUjt0GTG4a+JgWxXQpxXzTBq8fPUeGHfcYMMDPHJHm3yPOSjaeBwBGAHWXCdA=="],
Expand Down
11 changes: 11 additions & 0 deletions common/lib/panic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// unexpected error
export function panic(reason: string): never {
throw new Error(reason, {
cause: "panic",
});
}

// expected error
export function error(reason: string, code?: number): never {
throw new Error(reason, { cause: code });
}
116 changes: 0 additions & 116 deletions common/lib/result.ts

This file was deleted.

8 changes: 0 additions & 8 deletions common/lib/result/safeParseInt.ts

This file was deleted.

3 changes: 2 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
"author": "",
"license": "ISC",
"dependencies": {
"common": "workspace:common",
"@prisma/client": "^5.20.0",
"common": "workspace:common",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ずれてそう(まあいいけど)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bun add するとパッケージが名前順になるっぽい?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そうなのか、、、

"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"dotenv-cli": "^7.4.2",
"express": "^4.18.2",
"express-async-errors": "^3.1.1",
"firebase-admin": "^12.2.0",
"sharp": "^0.33.5",
"socket.io": "^4.7.5",
Expand Down
110 changes: 47 additions & 63 deletions server/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,45 +1,28 @@
//schema.prisma
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-3.0.x"]
previewFeatures = ["typedSql"]
binaryTargets = ["native", "debian-openssl-3.0.x"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

enum Day {
mon
tue
wed
thu
fri
sat
sun
other
}

model User {
// identifiers
id Int @id @default(autoincrement())
guid String @unique

// profile
name String
gender String
grade String
faculty String
department String
intro String
pictureUrl String

// bindings to other parts of this app
id Int @id @default(autoincrement())
guid String @unique
name String
gender String
grade String
faculty String
department String
intro String
pictureUrl String
enrollments Enrollment[]
sendingUsers Relationship[] @relation("sending") // 自分がマッチリクエストを送ったユーザー
receivingUsers Relationship[] @relation("receiving") // 自分にマッチリクエストを送ったユーザー
interests Interest[]
receivingUsers Relationship[] @relation("receiving")
sendingUsers Relationship[] @relation("sending")
}

model Avatar {
Expand All @@ -50,35 +33,27 @@ model Avatar {
model Picture {
hash String @id
data Bytes
key String // password
key String
}

model InterestSubject {
id Int @id @default(autoincrement())
name String
group String // such as Computer Science | name = ML
Interest Interest[] // ignore this
group String
Interest Interest[]

@@unique([name, group])
}

// User->Interest->InterestSubject
model Interest {
userId Int
user User @relation(fields: [userId], references: [id])
subjectId Int
subject InterestSubject @relation(fields: [subjectId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id])

@@unique([userId, subjectId])
}

// enum Gender {
// MALE
// FEMALE
// OTHER
// SECRET
// }

model Course {
id String @id
name String
Expand All @@ -87,64 +62,73 @@ model Course {
slots Slot[]
}

// コマ。1つの講義に対して複数存在しうる。
model Slot {
id Int @id @default(autoincrement())
course Course @relation(fields: [courseId], references: [id])
courseId String
period Int // 1-6. 0 の場合はなし (集中など)
day Day // 曜日。other の場合は集中など
period Int
day Day
course Course @relation(fields: [courseId], references: [id])

@@unique([courseId, period, day])
}

model Enrollment {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId Int
course Course @relation(fields: [courseId], references: [id])
courseId String
course Course @relation(fields: [courseId], references: [id])
user User @relation(fields: [userId], references: [id], onDelete: Cascade)

@@unique([userId, courseId])
}

model Relationship {
id Int @id @default(autoincrement())
status MatchingStatus
sendingUser User @relation("sending", fields: [sendingUserId], references: [id], onDelete: Cascade)
sendingUserId Int
receivingUser User @relation("receiving", fields: [receivingUserId], references: [id], onDelete: Cascade)
receivingUserId Int

messages Message[]
messages Message[]
receivingUser User @relation("receiving", fields: [receivingUserId], references: [id], onDelete: Cascade)
sendingUser User @relation("sending", fields: [sendingUserId], references: [id], onDelete: Cascade)

@@unique([sendingUserId, receivingUserId])
}

enum MatchingStatus {
PENDING
MATCHED
REJECTED
}

model SharedRoom {
id Int @id @default(autoincrement())
thumbnail String // URL to thumbnail picture
thumbnail String
name String
members Int[]
messages Message[]
}

model Message {
id Int @id @default(autoincrement())
creator Int // refers to UserId
createdAt DateTime @default(now()) // @readonly
creator Int
createdAt DateTime @default(now())
edited Boolean @default(false)
content String
isPicture Boolean // iff the message is a picture. if true, then content is a url of picture.
isPicture Boolean
read Boolean @default(false)
relation Relationship? @relation(fields: [relationId], references: [id], onDelete: Cascade)
relationId Int?
sharedRoom SharedRoom? @relation(fields: [sharedRoomId], references: [id], onDelete: Cascade)
sharedRoomId Int?
relation Relationship? @relation(fields: [relationId], references: [id], onDelete: Cascade)
sharedRoom SharedRoom? @relation(fields: [sharedRoomId], references: [id], onDelete: Cascade)
}

enum Day {
mon
tue
wed
thu
fri
sat
sun
other
}

enum MatchingStatus {
PENDING
MATCHED
REJECTED
}
Loading
Loading