-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
779 additions
and
3,759 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,4 @@ | ||
import type { MultipartFile } from '@fastify/multipart'; | ||
import type { DeletableTaskId } from 'api/@types/brandedId'; | ||
import type { TaskEntity } from 'api/@types/task'; | ||
import type { S3PutParams } from 'service/s3Client'; | ||
|
||
export type TaskCreateServerVal = { label: string; image?: MultipartFile }; | ||
|
||
export type TaskSaveVal = { task: TaskEntity; s3Params?: S3PutParams }; | ||
|
||
export type TaskDeleteVal = { deletableId: DeletableTaskId; task: TaskEntity }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,22 @@ | ||
import type { Prisma } from '@prisma/client'; | ||
import { s3 } from 'service/s3Client'; | ||
import type { TaskDeleteVal, TaskSaveVal } from '../model/taskEntity'; | ||
import type { TaskEntity } from 'api/@types/task'; | ||
import type { TaskDeleteVal } from '../model/taskEntity'; | ||
|
||
export const taskCommand = { | ||
save: async (tx: Prisma.TransactionClient, val: TaskSaveVal): Promise<void> => { | ||
if (val.s3Params !== undefined) await s3.put(val.s3Params); | ||
|
||
save: async (tx: Prisma.TransactionClient, task: TaskEntity): Promise<void> => { | ||
await tx.task.upsert({ | ||
where: { id: val.task.id }, | ||
update: { label: val.task.label, done: val.task.done, imageKey: val.task.image?.s3Key }, | ||
where: { id: task.id }, | ||
update: { label: task.label, done: task.done }, | ||
create: { | ||
id: val.task.id, | ||
label: val.task.label, | ||
done: val.task.done, | ||
imageKey: val.task.image?.s3Key, | ||
createdAt: new Date(val.task.createdTime), | ||
authorId: val.task.author.id, | ||
id: task.id, | ||
label: task.label, | ||
done: task.done, | ||
createdAt: new Date(task.createdTime), | ||
authorId: task.author.id, | ||
}, | ||
}); | ||
}, | ||
delete: async (tx: Prisma.TransactionClient, val: TaskDeleteVal): Promise<void> => { | ||
await tx.task.delete({ where: { id: val.deletableId } }); | ||
|
||
if (val.task.image !== undefined) await s3.delete(val.task.image.s3Key); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.