Skip to content

Commit 98e412d

Browse files
committed
remove contentType
1 parent fb485c6 commit 98e412d

File tree

7 files changed

+51
-80
lines changed

7 files changed

+51
-80
lines changed

app/routes/resources+/download-user-data.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export async function loader({ request }: Route.LoaderArgs) {
1818
id: true,
1919
createdAt: true,
2020
updatedAt: true,
21-
contentType: true,
21+
objectKey: true,
2222
},
2323
},
2424
notes: {
@@ -28,7 +28,7 @@ export async function loader({ request }: Route.LoaderArgs) {
2828
id: true,
2929
createdAt: true,
3030
updatedAt: true,
31-
contentType: true,
31+
objectKey: true,
3232
},
3333
},
3434
},

app/utils/auth.server.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ export async function signupWithConnection({
179179
data: {
180180
image: {
181181
create: {
182-
contentType: imageFile.type,
183182
objectKey: await uploadProfileImage(user.id, imageFile),
184183
},
185184
},

prisma/migrations/20250221001609_init/migration.sql renamed to prisma/migrations/20250221233640_init/migration.sql

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ CREATE TABLE "Note" (
2323
CREATE TABLE "NoteImage" (
2424
"id" TEXT NOT NULL PRIMARY KEY,
2525
"altText" TEXT,
26-
"contentType" TEXT NOT NULL,
2726
"objectKey" TEXT NOT NULL,
2827
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
2928
"updatedAt" DATETIME NOT NULL,
@@ -35,7 +34,6 @@ CREATE TABLE "NoteImage" (
3534
CREATE TABLE "UserImage" (
3635
"id" TEXT NOT NULL PRIMARY KEY,
3736
"altText" TEXT,
38-
"contentType" TEXT NOT NULL,
3937
"objectKey" TEXT NOT NULL,
4038
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
4139
"updatedAt" DATETIME NOT NULL,
@@ -188,7 +186,6 @@ CREATE UNIQUE INDEX "_RoleToUser_AB_unique" ON "_RoleToUser"("A", "B");
188186
-- CreateIndex
189187
CREATE INDEX "_RoleToUser_B_index" ON "_RoleToUser"("B");
190188

191-
192189
--------------------------------- Manual Seeding --------------------------
193190
-- Hey there, Kent here! This is how you can reliably seed your database with
194191
-- some data. You edit the migration.sql file and that will handle it for you.

prisma/schema.prisma

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ model Note {
4848
}
4949

5050
model NoteImage {
51-
id String @id @default(cuid())
52-
altText String?
53-
contentType String
54-
objectKey String
51+
id String @id @default(cuid())
52+
altText String?
53+
objectKey String
5554
5655
createdAt DateTime @default(now())
5756
updatedAt DateTime @updatedAt
@@ -64,10 +63,9 @@ model NoteImage {
6463
}
6564

6665
model UserImage {
67-
id String @id @default(cuid())
68-
altText String?
69-
contentType String
70-
objectKey String
66+
id String @id @default(cuid())
67+
altText String?
68+
objectKey String
7169
7270
createdAt DateTime @default(now())
7371
updatedAt DateTime @updatedAt

prisma/seed.ts

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { faker } from '@faker-js/faker'
2-
import { promiseHash } from 'remix-utils/promise'
32
import { prisma } from '#app/utils/db.server.ts'
43
import { MOCK_CODE_GITHUB } from '#app/utils/providers/constants'
54
import {
65
createPassword,
76
createUser,
87
getNoteImages,
98
getUserImages,
10-
img,
119
} from '#tests/db-utils.ts'
1210
import { insertGitHubUser } from '#tests/mocks/github.ts'
1311

@@ -37,8 +35,6 @@ async function seed() {
3735
await prisma.userImage.create({
3836
data: {
3937
userId: user.id,
40-
contentType: userImage.contentType,
41-
altText: userImage.altText,
4238
objectKey: userImage.objectKey,
4339
},
4440
})
@@ -65,7 +61,6 @@ async function seed() {
6561
await prisma.noteImage.create({
6662
data: {
6763
noteId: note.id,
68-
contentType: noteImage.contentType,
6964
altText: noteImage.altText,
7065
objectKey: noteImage.objectKey,
7166
},
@@ -78,38 +73,38 @@ async function seed() {
7873

7974
console.time(`🐨 Created admin user "kody"`)
8075

81-
const kodyImages = await promiseHash({
82-
kodyUser: img({ objectKey: 'user/kody.png' }),
83-
cuteKoala: img({
76+
const kodyImages = {
77+
kodyUser: { objectKey: 'user/kody.png' },
78+
cuteKoala: {
8479
altText: 'an adorable koala cartoon illustration',
8580
objectKey: 'kody-notes/cute-koala.png',
86-
}),
87-
koalaEating: img({
81+
},
82+
koalaEating: {
8883
altText: 'a cartoon illustration of a koala in a tree eating',
8984
objectKey: 'kody-notes/koala-eating.png',
90-
}),
91-
koalaCuddle: img({
85+
},
86+
koalaCuddle: {
9287
altText: 'a cartoon illustration of koalas cuddling',
9388
objectKey: 'kody-notes/koala-cuddle.png',
94-
}),
95-
mountain: img({
89+
},
90+
mountain: {
9691
altText: 'a beautiful mountain covered in snow',
9792
objectKey: 'kody-notes/mountain.png',
98-
}),
99-
koalaCoder: img({
93+
},
94+
koalaCoder: {
10095
altText: 'a koala coding at the computer',
10196
objectKey: 'kody-notes/koala-coder.png',
102-
}),
103-
koalaMentor: img({
97+
},
98+
koalaMentor: {
10499
altText:
105100
'a koala in a friendly and helpful posture. The Koala is standing next to and teaching a woman who is coding on a computer and shows positive signs of learning and understanding what is being explained.',
106101
objectKey: 'kody-notes/koala-mentor.png',
107-
}),
108-
koalaSoccer: img({
102+
},
103+
koalaSoccer: {
109104
altText: 'a cute cartoon koala kicking a soccer ball on a soccer field ',
110105
objectKey: 'kody-notes/koala-soccer.png',
111-
}),
112-
})
106+
},
107+
}
113108

114109
const githubUser = await insertGitHubUser(MOCK_CODE_GITHUB)
115110

@@ -130,8 +125,6 @@ async function seed() {
130125
await prisma.userImage.create({
131126
data: {
132127
userId: kody.id,
133-
contentType: kodyImages.kodyUser.contentType,
134-
altText: kodyImages.kodyUser.altText,
135128
objectKey: kodyImages.kodyUser.objectKey,
136129
},
137130
})
@@ -239,7 +232,6 @@ async function seed() {
239232
await prisma.noteImage.create({
240233
data: {
241234
noteId: note.id,
242-
contentType: image.contentType,
243235
altText: image.altText,
244236
objectKey: image.objectKey,
245237
},

tests/db-utils.ts

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -35,80 +35,66 @@ export function createPassword(password: string = faker.internet.password()) {
3535
}
3636
}
3737

38-
let noteImages: Array<Awaited<ReturnType<typeof img>>> | undefined
38+
let noteImages: Array<{ altText: string; objectKey: string }> | undefined
3939
export async function getNoteImages() {
4040
if (noteImages) return noteImages
4141

4242
noteImages = await Promise.all([
43-
img({
43+
{
4444
altText: 'a nice country house',
4545
objectKey: 'notes/0.png',
46-
}),
47-
img({
46+
},
47+
{
4848
altText: 'a city scape',
4949
objectKey: 'notes/1.png',
50-
}),
51-
img({
50+
},
51+
{
5252
altText: 'a sunrise',
5353
objectKey: 'notes/2.png',
54-
}),
55-
img({
54+
},
55+
{
5656
altText: 'a group of friends',
5757
objectKey: 'notes/3.png',
58-
}),
59-
img({
58+
},
59+
{
6060
altText: 'friends being inclusive of someone who looks lonely',
6161
objectKey: 'notes/4.png',
62-
}),
63-
img({
62+
},
63+
{
6464
altText: 'an illustration of a hot air balloon',
6565
objectKey: 'notes/5.png',
66-
}),
67-
img({
66+
},
67+
{
6868
altText:
6969
'an office full of laptops and other office equipment that look like it was abandoned in a rush out of the building in an emergency years ago.',
7070
objectKey: 'notes/6.png',
71-
}),
72-
img({
71+
},
72+
{
7373
altText: 'a rusty lock',
7474
objectKey: 'notes/7.png',
75-
}),
76-
img({
75+
},
76+
{
7777
altText: 'something very happy in nature',
7878
objectKey: 'notes/8.png',
79-
}),
80-
img({
79+
},
80+
{
8181
altText: `someone at the end of a cry session who's starting to feel a little better.`,
8282
objectKey: 'notes/9.png',
83-
}),
83+
},
8484
])
8585

8686
return noteImages
8787
}
8888

89-
let userImages: Array<Awaited<ReturnType<typeof img>>> | undefined
89+
let userImages: Array<{ objectKey: string }> | undefined
9090
export async function getUserImages() {
9191
if (userImages) return userImages
9292

9393
userImages = await Promise.all(
94-
Array.from({ length: 10 }, (_, index) =>
95-
img({ objectKey: `user/${index}.jpg` }),
96-
),
94+
Array.from({ length: 10 }, (_, index) => ({
95+
objectKey: `user/${index}.jpg`,
96+
})),
9797
)
9898

9999
return userImages
100100
}
101-
102-
export async function img({
103-
altText,
104-
objectKey,
105-
}: {
106-
altText?: string
107-
objectKey: string
108-
}) {
109-
return {
110-
altText,
111-
objectKey,
112-
contentType: objectKey.endsWith('.png') ? 'image/png' : 'image/jpeg',
113-
}
114-
}

tests/e2e/note-images.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ function createNoteWithImage() {
124124
images: {
125125
create: {
126126
altText: 'cute koala',
127-
contentType: 'image/png',
128127
objectKey: 'kody-notes/cute-koala.png',
129128
},
130129
},
@@ -133,7 +132,7 @@ function createNoteWithImage() {
133132
'id' | 'createdAt' | 'updatedAt' | 'type' | 'ownerId'
134133
> & {
135134
images: {
136-
create: Pick<NoteImage, 'altText' | 'contentType' | 'objectKey'>
135+
create: Pick<NoteImage, 'altText' | 'objectKey'>
137136
}
138137
}
139138
}

0 commit comments

Comments
 (0)