Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.
Open
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
6 changes: 3 additions & 3 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
Expand All @@ -78,7 +78,7 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:
key: ${{ secrets.VPS_SSH_KEY }}
script: |
cd /home/${{ secrets.VPS_USERNAME }}/credential-showcase-api

# Deploy API server if changed
if [[ "${{ needs.determine-changes.outputs.api_server }}" == "true" ]]; then
export TAG=${{ github.sha }} && sudo -E docker compose -f docker/dev/docker-compose.yml pull credential-showcase-api-server
Expand Down
21 changes: 21 additions & 0 deletions .husky/pre-commit
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A TypeScript-based monorepo for the Credential Showcase API, consisting of backe

# credential-showcase-api-server

the backend server for the Credential Showcase application. It provides REST API endpoints for managing and showcasing credentials.
the backend server for the Credential Showcase application. It provides REST API endpoints for managing and showcasing credentials.

# credential-showcase-openapi

Expand Down
2 changes: 1 addition & 1 deletion apps/credential-showcase-api-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"types": "dist/index.d.ts",
"scripts": {
"start": "ts-node src/index.ts",
"dev": "ts-node-dev src/index.ts",
"dev": "ts-node-dev --transpile-only src/index.ts",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolves 3min startup time

"build": "tsc",
"build:clean": "tsc --build --clean && tsc --build",
"migration:generate": "npx drizzle-kit generate --config=drizzle.config.ts --name=credential-showcase-api"
Expand Down
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> {
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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) {
Expand All @@ -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> {
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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)
Expand Down
Loading