Skip to content

Commit 481fe90

Browse files
authored
Merge pull request #89 from daneedev/feature/upload-system
Notes & Upload system
2 parents c91c374 + 4748ffa commit 481fe90

13 files changed

Lines changed: 812 additions & 9 deletions

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ FRONTEND_PORT=3000
1515

1616
# Development
1717
DEBUG=true
18-
VITE_DEBUG=true
18+
VITE_DEBUG=true
19+
20+
UPLOAD_DIR=./uploads
21+
MAX_FILE_SIZE=5 # in MB

backend/package-lock.json

Lines changed: 37 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"dotenv": "^17.3.1",
3636
"pg": "^8.18.0",
3737
"reflect-metadata": "^0.2.2",
38-
"rxjs": "^7.8.1"
38+
"rxjs": "^7.8.1",
39+
"sanitize-filename": "^1.6.4"
3940
},
4041
"devDependencies": {
4142
"@eslint/eslintrc": "^3.2.0",
@@ -45,6 +46,7 @@
4546
"@nestjs/testing": "^11.0.1",
4647
"@types/express": "^5.0.0",
4748
"@types/jest": "^30.0.0",
49+
"@types/multer": "^2.1.0",
4850
"@types/node": "^22.19.11",
4951
"@types/pg": "^8.16.0",
5052
"@types/supertest": "^6.0.2",

backend/prisma/schema.prisma

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
66

77
generator client {
8-
provider = "prisma-client"
9-
output = "../src/generated/prisma"
10-
moduleFormat = "cjs"
8+
provider = "prisma-client"
9+
output = "../src/generated/prisma"
10+
moduleFormat = "cjs"
1111
}
1212

1313
datasource db {
@@ -33,6 +33,7 @@ model User {
3333
updatedAt DateTime @updatedAt
3434
assignments Assignment[] @relation("UserAssignments")
3535
classes ClassUser[]
36+
notes Note[]
3637
}
3738

3839
model Class {
@@ -41,9 +42,9 @@ model Class {
4142
inviteCode String @unique
4243
createdAt DateTime @default(now())
4344
updatedAt DateTime @updatedAt
44-
assignments Assignment[]
4545
subjects Subject[]
4646
users ClassUser[]
47+
assignments Assignment[]
4748
}
4849

4950
model ClassUser {
@@ -79,6 +80,32 @@ model Subject {
7980
classId String
8081
class Class @relation(fields: [classId], references: [id])
8182
assignments Assignment[]
83+
notes Note[]
8284
createdAt DateTime @default(now())
8385
updatedAt DateTime @updatedAt
8486
}
87+
88+
model Note {
89+
id String @id @default(uuid())
90+
subjectId String
91+
subject Subject @relation(fields: [subjectId], references: [id])
92+
authorId String
93+
author User @relation(fields: [authorId], references: [id])
94+
content String
95+
files File[]
96+
name String
97+
createdAt DateTime @default(now())
98+
updatedAt DateTime @updatedAt
99+
}
100+
101+
model File {
102+
id String @id @default(uuid())
103+
originalName String
104+
mimetype String
105+
size Int
106+
storage String @default("local")
107+
noteId String
108+
note Note @relation(fields: [noteId], references: [id])
109+
createdAt DateTime @default(now())
110+
updatedAt DateTime @updatedAt
111+
}

backend/src/app.module.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,20 @@ import { ClassesModule } from './classes/classes.module';
88
import { AssignmentsModule } from './assignments/assignments.module';
99
import { SubjectsModule } from './subjects/subjects.module';
1010
import { PrismaModule } from './prisma/prisma.module';
11+
import { FilesModule } from './files/files.module';
12+
import { NotesModule } from './notes/notes.module';
1113

1214
@Module({
13-
imports: [PrismaModule, AuthModule, UsersModule, ClassesModule, AssignmentsModule, SubjectsModule],
15+
imports: [
16+
PrismaModule,
17+
AuthModule,
18+
UsersModule,
19+
ClassesModule,
20+
AssignmentsModule,
21+
SubjectsModule,
22+
NotesModule,
23+
FilesModule,
24+
],
1425
providers: [
1526
{
1627
provide: APP_INTERCEPTOR,

backend/src/dto/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export * from './auth.dto';
22
export * from './users.dto';
33
export * from './classes.dto';
44
export * from './assignments.dto';
5-
export * from './subjects.dto';
5+
export * from './subjects.dto';
6+
export * from './notes.dto';

backend/src/dto/notes.dto.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { ApiProperty } from '@nestjs/swagger';
2+
import { IsNotEmpty, IsString } from 'class-validator';
3+
4+
export class CreateNoteDto {
5+
@IsString()
6+
@IsNotEmpty()
7+
@ApiProperty({
8+
description: 'Name of the note',
9+
example: 'Math Homework 1',
10+
})
11+
name: string;
12+
@IsString()
13+
@IsNotEmpty()
14+
@ApiProperty({
15+
description: 'Subject ID of the assignment',
16+
example: 'UUID of the subject',
17+
})
18+
subjectId: string;
19+
@IsString()
20+
@IsNotEmpty()
21+
@ApiProperty({
22+
description: 'Content of the note',
23+
example:
24+
'This is the content of the note. JSON format can be used for rich text.',
25+
})
26+
content: string;
27+
}
28+
29+
export class UpdateNoteDto {
30+
@IsString()
31+
@ApiProperty({
32+
description: 'Name of the note',
33+
example: 'Math Homework 1',
34+
})
35+
name?: string;
36+
@IsString()
37+
@ApiProperty({
38+
description: 'Content of the note',
39+
example:
40+
'This is the content of the note. JSON format can be used for rich text.',
41+
})
42+
content?: string;
43+
}

0 commit comments

Comments
 (0)