Skip to content

Commit 2a2ec73

Browse files
committed
removed eslint formatting and added prettier formatting
1 parent 53c4409 commit 2a2ec73

File tree

5 files changed

+52
-101
lines changed

5 files changed

+52
-101
lines changed

package-lock.json

Lines changed: 13 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"next": "^15.4.10",
4646
"next-auth": "^4.24.11",
4747
"postgres": "^3.3.5",
48+
"prettier-plugin-sort-imports": "^1.8.9",
4849
"react": "^18.2.0",
4950
"react-day-picker": "^8.9.1",
5051
"react-dom": "^18.2.0",
@@ -74,7 +75,6 @@
7475
"eslint-plugin-jsx-a11y": "^6.5.1",
7576
"eslint-plugin-react": "^7.29.4",
7677
"eslint-plugin-react-hooks": "^4.4.0",
77-
"eslint-plugin-simple-import-sort": "^7.0.0",
7878
"jest": "^29.7.0",
7979
"postcss": "^8.4.27",
8080
"prettier": "^3.2.5",

src/app/api/files/upload/route.ts

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ const uploadFormSchema = z.object({
1515
prefix: z.string().min(1, { message: 'Prefix is missing' }),
1616
courseNumber: z.string().min(1, { message: 'Course number is missing' }),
1717
sectionCode: z.string().min(1, { message: 'Section code is missing' }),
18-
professor: z.string().min(1 , { message: 'Professor is missing' }),
18+
professor: z.string().min(1, { message: 'Professor is missing' }),
1919
term: z.enum(['Spring', 'Summer', 'Fall']),
20-
year: z.coerce.number({ message: 'Year is missing'}),
21-
})
20+
year: z.coerce.number({ message: 'Year is missing' }),
21+
});
2222

2323
// Upload file to database w/ file metadata (Local)
2424
export async function POST(req: Request) {
@@ -42,17 +42,11 @@ export async function POST(req: Request) {
4242
const newFile = data.file as File;
4343

4444
if (!(newFile instanceof File)) {
45-
return NextResponse.json(
46-
{ error: 'Invalid file upload' },
47-
{ status: 400 },
48-
);
45+
return NextResponse.json({ error: 'Invalid file upload' }, { status: 400 });
4946
}
50-
47+
5148
if (newFile.size === 0) {
52-
return NextResponse.json(
53-
{ error: 'File is empty' },
54-
{ status: 400 },
55-
);
49+
return NextResponse.json({ error: 'File is empty' }, { status: 400 });
5650
}
5751

5852
if (!allowedTypes.includes(newFile.type)) {
@@ -76,10 +70,7 @@ export async function POST(req: Request) {
7670
});
7771

7872
if (!sectionData) {
79-
return NextResponse.json(
80-
{ error: 'Section not found' },
81-
{ status: 404 },
82-
);
73+
return NextResponse.json({ error: 'Section not found' }, { status: 404 });
8374
}
8475

8576
try {
@@ -96,10 +87,10 @@ export async function POST(req: Request) {
9687
const fileMetadata = {
9788
authorId: session.user.id,
9889
sectionId: sectionData.id,
99-
fileTitle: newFile.name, // required by schema
100-
fileName: newFile.name, // required by schema
90+
fileTitle: newFile.name, // required by schema
91+
fileName: newFile.name, // required by schema
10192
};
102-
93+
10394
const result = await db.insert(file).values(fileMetadata).returning();
10495

10596
return NextResponse.json(
@@ -108,9 +99,6 @@ export async function POST(req: Request) {
10899
);
109100
} catch (err) {
110101
console.error('File upload error:', err);
111-
return NextResponse.json(
112-
{ error: 'File upload failed' },
113-
{ status: 500 },
114-
);
102+
return NextResponse.json({ error: 'File upload failed' }, { status: 500 });
115103
}
116104
}

src/server/db/schema/file.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,21 @@ export const file = pgTable(
2525
.notNull()
2626
.references(() => user.id, { onDelete: 'cascade' }), // Could be 'set null' too, depending on what we want to do with it.
2727

28-
sectionId: varchar('section_id', { length: 6 })
29-
.references(() => section.id, { onDelete: 'set null' }),
28+
sectionId: varchar('section_id', { length: 6 }).references(
29+
() => section.id,
30+
{ onDelete: 'set null' },
31+
),
3032

31-
fileTitle: text('file_title')
32-
.notNull(),
33+
fileTitle: text('file_title').notNull(),
3334

34-
fileName: text('file_name')
35-
.notNull(),
35+
fileName: text('file_name').notNull(),
3636

3737
publishDate: timestamp('publish_date', { withTimezone: true })
3838
.notNull()
3939
.defaultNow(),
4040

41-
likes: integer('likes')
42-
.notNull()
43-
.default(0),
44-
saves: integer('saves')
45-
.notNull()
46-
.default(0),
41+
likes: integer('likes').notNull().default(0),
42+
saves: integer('saves').notNull().default(0),
4743

4844
// Edit flag for future workflows
4945
edited: boolean('edited').notNull().default(false),
@@ -55,7 +51,7 @@ export const file = pgTable(
5551
.notNull()
5652
.defaultNow(),
5753
},
58-
(t) => ([
54+
(t) => [
5955
// REVIEW: This is CASE SENSITIVE. File != file similar to Linux.
6056
// So a user could have "Lecture 1 Notes" and "lecture 1 notes".
6157
// I would recommend adding a PG extension for to support insensitivity.
@@ -66,7 +62,7 @@ export const file = pgTable(
6662

6763
check('file_likes_nonneg', sql`${t.likes} >= 0`),
6864
check('file_saves_nonneg', sql`${t.saves} >= 0`),
69-
]),
65+
],
7066
);
7167

7268
export const fileRelations = relations(file, ({ one }) => ({
@@ -78,4 +74,4 @@ export const fileRelations = relations(file, ({ one }) => ({
7874
fields: [file.sectionId],
7975
references: [section.id],
8076
}),
81-
}));
77+
}));

src/server/db/schema/section.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,20 @@ export const section = pgTable(
2222
.primaryKey(),
2323

2424
// "CS" or "CE", short and indexable
25-
prefix: varchar('prefix', { length: 4 })
26-
.notNull(),
25+
prefix: varchar('prefix', { length: 4 }).notNull(),
2726

2827
// Course number like 1200
29-
number: varchar('number', { length: 4 })
30-
.notNull(),
28+
number: varchar('number', { length: 4 }).notNull(),
3129

3230
// Section code like "001"
33-
sectionCode: varchar('section_code', { length: 3 })
34-
.notNull(),
31+
sectionCode: varchar('section_code', { length: 3 }).notNull(),
3532

3633
// Semester split into term + year for better filtering
37-
term: termEnum('term')
38-
.notNull(),
39-
year: smallint('year')
40-
.notNull(),
34+
term: termEnum('term').notNull(),
35+
year: smallint('year').notNull(),
4136

4237
professor: text('professor'),
43-
numberOfNotes: integer('number_of_notes')
44-
.notNull()
45-
.default(0),
38+
numberOfNotes: integer('number_of_notes').notNull().default(0),
4639

4740
// Not required, but good practice usually
4841
createdAt: timestamp('created_at', { withTimezone: true })
@@ -52,14 +45,20 @@ export const section = pgTable(
5245
.notNull()
5346
.defaultNow(),
5447
},
55-
(t) => ([
56-
uniqueIndex('section_unique_idx').on(t.prefix, t.number, t.sectionCode, t.term, t.year),
48+
(t) => [
49+
uniqueIndex('section_unique_idx').on(
50+
t.prefix,
51+
t.number,
52+
t.sectionCode,
53+
t.term,
54+
t.year,
55+
),
5756
index('section_by_course_idx').on(t.prefix, t.number),
5857
index('section_by_professor_idx').on(t.professor),
5958
index('section_by_semester_idx').on(t.term, t.year),
60-
]),
59+
],
6160
);
6261

6362
export const sectionRelations = relations(section, ({ many }) => ({
6463
files: many(file),
65-
}));
64+
}));

0 commit comments

Comments
 (0)