This repository was archived by the owner on Mar 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
chore: implemented expand QPs for showcase #52
Open
sanderPostma
wants to merge
11
commits into
develop
Choose a base branch
from
feature/SHOWCASE-159
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c948448
chore: implemented expand QPs for showcase
sanderPostma b929167
chore: cleanup & pre-commit fix
sanderPostma a97e767
chore: pre-commit fix
sanderPostma fa8f8dc
Merge remote-tracking branch 'origin/develop' into feature/SHOWCASE-159
sanderPostma 1393c61
Merge remote-tracking branch 'origin/develop' into feature/SHOWCASE-159
sanderPostma 1db4c29
chore: So not ignore invalid expand parameters
sanderPostma cb2df61
chore: Save changes
sanderPostma 9b42955
chore: post-merge
sanderPostma a1dd0ea
Merge remote-tracking branch 'origin/develop' into feature/SHOWCASE-159
sanderPostma 4cda341
chore: final fixes
sanderPostma c7a85fa
chore: final fixes
sanderPostma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 +1,22 @@ | ||
| # Check if prettier would make changes | ||
| if ! pnpm prettier --check; then | ||
| echo "Error: Prettier check failed. Please format your code before committing." | ||
| echo "You can run 'pnpm prettier' to fix formatting issues." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Stash unstaged and untracked changes, keeping staged files intact | ||
| stash_ref=$(git stash push --keep-index --include-untracked -m "pre-commit-$(date +%s)") | ||
| echo "Saved unstaged files to stash, ref: $stash_ref" | ||
|
|
||
| # Run prettier formatting | ||
| pnpm prettier | ||
|
|
||
| # Stage only prettier modified files | ||
| git add -u | ||
|
|
||
| # Restore unstaged changes from stash, if any | ||
| if [ "$stash_ref" != "No local changes to save" ]; then | ||
| echo "Restoring stash" | ||
| git stash pop >/dev/null 2>&1 | ||
| fi |
This file contains hidden or 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 hidden or 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 hidden or 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,26 +1,28 @@ | ||
| import { BadRequestError, Body, Delete, Get, HttpCode, JsonController, OnUndefined, Param, Post, Put } from 'routing-controllers' | ||
| import { BadRequestError, Body, Delete, Get, HttpCode, JsonController, OnUndefined, Param, Post, Put, QueryParam } from 'routing-controllers' | ||
| import { Service } from 'typedi' | ||
| import { | ||
| ShowcaseResponse, | ||
| ShowcaseResponseFromJSONTyped, | ||
| instanceOfShowcaseRequest, | ||
| ShowcaseExpand, | ||
| ShowcaseRequest, | ||
| ShowcaseRequestToJSONTyped, | ||
| ShowcaseResponse, | ||
| ShowcaseResponseFromJSONTyped, | ||
| ShowcasesResponse, | ||
| ShowcasesResponseFromJSONTyped, | ||
| instanceOfShowcaseRequest, | ||
| } from 'credential-showcase-openapi' | ||
| import ShowcaseService from '../services/ShowcaseService' | ||
| import { showcaseDTOFrom } from '../utils/mappers' | ||
| import { normalizeExpandParams } from '../utils/normalize' | ||
| import { ShowcaseService } from '../services/ShowcaseService' | ||
|
|
||
| @JsonController('/showcases') | ||
| @Service() | ||
| class ShowcaseController { | ||
| constructor(private showcaseService: ShowcaseService) {} | ||
|
|
||
| @Get('/') | ||
| public async getAll(): Promise<ShowcasesResponse> { | ||
| public async getAll(@QueryParam('expand') expand?: ShowcaseExpand[]): Promise<ShowcasesResponse> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i do not see id's being returned. now it is returning empty arrays
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. open 14-03 |
||
| try { | ||
| const result = await this.showcaseService.getShowcases() | ||
| const result = await this.showcaseService.getShowcases({ expand: normalizeExpandParams(expand) }) | ||
| const showcases = result.map((showcase) => showcaseDTOFrom(showcase)) | ||
| return ShowcasesResponseFromJSONTyped({ showcases }, false) | ||
| } catch (e) { | ||
|
|
@@ -32,10 +34,10 @@ class ShowcaseController { | |
| } | ||
|
|
||
| @Get('/:slug') | ||
| public async getOne(@Param('slug') slug: string): Promise<ShowcaseResponse> { | ||
| const id = await this.showcaseService.getIdBySlug(slug) | ||
| public async getOne(@Param('slug') slug: string, @QueryParam('expand') expand?: ShowcaseExpand[]): Promise<ShowcaseResponse> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i do not see id's being returned. now it is returning empty arrays
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. open 14-03 |
||
| const id = await this.showcaseService.getIdBySlug({ slug }) | ||
| try { | ||
| const result = await this.showcaseService.getShowcase(id) | ||
| const result = await this.showcaseService.getShowcase({ id, expand: normalizeExpandParams(expand) }) | ||
| return ShowcaseResponseFromJSONTyped({ showcase: showcaseDTOFrom(result) }, false) | ||
| } catch (e) { | ||
| if (e.httpCode !== 404) { | ||
|
|
@@ -52,7 +54,7 @@ class ShowcaseController { | |
| if (!instanceOfShowcaseRequest(showcaseRequest)) { | ||
| return Promise.reject(new BadRequestError()) | ||
| } | ||
| const result = await this.showcaseService.createShowcase(ShowcaseRequestToJSONTyped(showcaseRequest)) | ||
| const result = await this.showcaseService.createShowcase({ showcase: ShowcaseRequestToJSONTyped(showcaseRequest) }) | ||
| return ShowcaseResponseFromJSONTyped({ showcase: showcaseDTOFrom(result) }, false) | ||
| } catch (e) { | ||
| if (e.httpCode !== 404) { | ||
|
|
@@ -64,12 +66,13 @@ class ShowcaseController { | |
|
|
||
| @Put('/:slug') | ||
| public async put(@Param('slug') slug: string, @Body() showcaseRequest: ShowcaseRequest): Promise<ShowcaseResponse> { | ||
| const id = await this.showcaseService.getIdBySlug(slug) | ||
| const id = await this.showcaseService.getIdBySlug({ slug }) | ||
| try { | ||
| if (!instanceOfShowcaseRequest(showcaseRequest)) { | ||
| return Promise.reject(new BadRequestError()) | ||
| } | ||
| const result = await this.showcaseService.updateShowcase(id, ShowcaseRequestToJSONTyped(showcaseRequest)) | ||
| const result = await this.showcaseService.updateShowcase({ id, showcase: ShowcaseRequestToJSONTyped(showcaseRequest) }) | ||
|
|
||
| return ShowcaseResponseFromJSONTyped({ showcase: showcaseDTOFrom(result) }, false) | ||
| } catch (e) { | ||
| if (e.httpCode !== 404) { | ||
|
|
@@ -82,9 +85,9 @@ class ShowcaseController { | |
| @OnUndefined(204) | ||
| @Delete('/:slug') | ||
| public async delete(@Param('slug') slug: string): Promise<void> { | ||
| const id = await this.showcaseService.getIdBySlug(slug) | ||
| const id = await this.showcaseService.getIdBySlug({ slug }) | ||
| try { | ||
| return this.showcaseService.deleteShowcase(id) | ||
| return this.showcaseService.deleteShowcase({ id }) | ||
| } catch (e) { | ||
| if (e.httpCode !== 404) { | ||
| console.error(`Delete showcase id=${id} failed:`, e) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolves 3min startup time