Skip to content

マイページ画面のAPIを作成#81

Open
junji-s wants to merge 2 commits intomainfrom
feature/mypage-api
Open

マイページ画面のAPIを作成#81
junji-s wants to merge 2 commits intomainfrom
feature/mypage-api

Conversation

@junji-s
Copy link
Contributor

@junji-s junji-s commented Sep 6, 2023

PRの内容

マイページ画面のAPIを作成

動作確認方法

以下のような感じでpostmanとかでpostしてもらえれば!

{
    "nickname": "山田太郎",
    "biography": "自己紹介です",
    "multiInputItems": [
        {
            "value": "https://www.test.co.jp/"
        },
        {
            "value": "https://www.test2.co.jp/"
        }
    ],
    "profileImage" : ""
}

その他連絡事項

  • 悩んでいるところ、特にレビューしてほしいところなどがあれば

@junji-s junji-s changed the title Feature/mypage api マイページ画面のAPIを作成 Sep 6, 2023
@junji-s
Copy link
Contributor Author

junji-s commented Sep 6, 2023

フロント側と合わせる必要があるので、マージせずにコードだけ確認してもらえると、嬉しいです。

Copy link
Collaborator

@tekihei2317 tekihei2317 left a comment

Choose a reason for hiding this comment

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

コードを確認しました!
いくつかコメントしたので、フロント実装の際に確認していただければと思います!

if (user.imageId) {
await deleteImageInCloudinary(user.imageId);
}
const imageId = await uploadImageToCloudinary(input?.profileImage);
Copy link
Collaborator

Choose a reason for hiding this comment

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

inputにプロフィール画像がある場合だけアップロードする必要がありそうです!

/**
* マイページの情報を更新する
*/
export const updateProfile = protectedProcedure.input(MypageInput).query(async ({ ctx, input }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

更新系のAPIはmutationで定義するのが良いかと思います!

https://trpc.io/docs/server/procedures

value: z.string().url({ message: ERROR_INVALID_URL }).max(191, { message: ERROR_MAX_LENGTH }),
})
),
profileImage: z.string().optional(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

フロント側ではファイルを受け取るので、繋ぎ込みの際に前の記述(z.custom<FileList>()...)に戻す必要があるかもです。

現状はフロントとサーバー側は別のスキーマを使っているので、こちらもそうするか、あるいはz.mergeなどを使って差分だけ上書きしても良いかもしれません。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants