Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add client api of findDeckListByUserId api #105

Merged
merged 2 commits into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions packages/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ const card = JSON_APIS({
// Todo : change to session
createCard: ({ createCardDto }: { createCardDto: CreateCardDto }) =>
client.public.post<{ result: boolean }>('cards', createCardDto),
// get card by id
/* get List of Cards in deck: Get card information by deck id */
// Todo : change to session
getCards: ({ id }: { id: string }) => client.public.get<{ result: Card[] | null }>(`decks/id=${id}/cards`),
getCards: ({ deckId }: { deckId: string }) =>
client.public.get<{ result: Card[] | null }>(`decks/id=${deckId}/cards`),
/* delete card by id */
// Todo : change to session
deleteCard: ({ id }: { id: string }) => client.public.delete<{ result: boolean }>(`cards/id=${id}`),
Expand All @@ -40,9 +41,12 @@ const deck = JSON_APIS({
client.public.post<{ deck_id: string }>('decks', createDeckDto),
/* get Deck: Get card information by deck id */
// Todo : change to session
getDeck: ({ id }: { id: string }) => client.public.get<{ result: Deck | null }>(`decks/id=${id}`),
/* get List of Cards in deck: Get card information by deck id */
getDeck: ({ deckId }: { deckId: string }) => client.public.get<{ result: Deck | null }>(`decks/id=${deckId}`),
/* Get all deck info */
getAllDeck: () => client.public.get<{ result: Deck[] }>(`decks`),
/* Get deck list of user id */
getDeckListByUserId: ({ userId }: { userId: string }) =>
client.session.get<{ result: Deck[] | null }>(`decks/user/${userId}`),
});

export const api = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class DeckController {
}

@Get('/user/:userId')
async findByUserId(@Param('userId') userId: string): Promise<{ result: Deck[] | null }> {
async findByUserId(@Param('userId') userId: string): Promise<{ result: Deck[] | [] }> {
const result = await this.deckService.findDeckListByUserId(userId);
return { result: result };
}
Expand Down
2 changes: 1 addition & 1 deletion packages/service-backend/src/modules/deck/DeckService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class DeckService {
return await this.deckRepository.findAll();
}

async findDeckListByUserId(userId: string): Promise<Deck[]> {
async findDeckListByUserId(userId: string): Promise<Deck[] | []> {
return await this.deckRepository.findByUserId(userId);
}

Expand Down