-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduced isFeatured option in member, team, project, pl-events
- added new api to fetch featured member, team, project, events
- Loading branch information
1 parent
d54ef20
commit f5dba43
Showing
19 changed files
with
197 additions
and
1 deletion.
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
11 changes: 11 additions & 0 deletions
11
...web-api/prisma/migrations/20240813093750_team_project_event_featured_option/migration.sql
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- AlterTable | ||
ALTER TABLE "Member" ADD COLUMN "isFeatured" BOOLEAN DEFAULT false; | ||
|
||
-- AlterTable | ||
ALTER TABLE "PLEvent" ADD COLUMN "isFeatured" BOOLEAN DEFAULT false; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Project" ADD COLUMN "isFeatured" BOOLEAN DEFAULT false; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Team" ADD COLUMN "isFeatured" BOOLEAN DEFAULT false; |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Controller, Req } from '@nestjs/common'; | ||
import { Api, initNestServer } from '@ts-rest/nest'; | ||
import { Request } from 'express'; | ||
import { apiHome } from 'libs/contracts/src/lib/contract-home'; | ||
import { HomeService } from './home.service'; | ||
|
||
const server = initNestServer(apiHome); | ||
type RouteShape = typeof server.routeShapes; | ||
|
||
@Controller() | ||
export class HomeController { | ||
constructor(private homeService: HomeService) {} | ||
|
||
@Api(server.route.getAllFeaturedData) | ||
async getAllFeaturedData(@Req() request: Request) { | ||
return await this.homeService.fetchAllFeaturedData(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { HomeController } from './home.controller'; | ||
import { HomeService } from './home.service'; | ||
import { MembersModule } from '../members/members.module'; | ||
import { TeamsModule } from '../teams/teams.module'; | ||
import { ProjectsModule} from '../projects/projects.module'; | ||
import { PLEventsModule } from '../pl-events/pl-events.module'; | ||
|
||
@Module({ | ||
controllers: [HomeController], | ||
providers: [ | ||
HomeService | ||
], | ||
imports:[ | ||
MembersModule, | ||
TeamsModule, | ||
ProjectsModule, | ||
PLEventsModule | ||
], | ||
exports: [ | ||
HomeService | ||
] | ||
}) | ||
export class HomeModule {} |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Injectable, InternalServerErrorException } from '@nestjs/common'; | ||
import { LogService } from '../shared/log.service'; | ||
import { MembersService } from '../members/members.service'; | ||
import { TeamsService } from '../teams/teams.service'; | ||
import { PLEventsService } from '../pl-events/pl-events.service'; | ||
import { ProjectsService } from '../projects/projects.service'; | ||
|
||
@Injectable() | ||
export class HomeService { | ||
constructor( | ||
private logger: LogService, | ||
private memberService: MembersService, | ||
private teamsService: TeamsService, | ||
private plEventsService: PLEventsService, | ||
private projectsService: ProjectsService | ||
) {} | ||
|
||
async fetchAllFeaturedData() { | ||
try { | ||
const filter = { where : { isFeatured: true }} | ||
return { | ||
members: await this.memberService.findAll(filter), | ||
teams: await this.teamsService.findAll(filter), | ||
events: await this.plEventsService.getPLEvents(filter), | ||
projects: await this.projectsService.getProjects(filter) | ||
}; | ||
} | ||
catch (error) { | ||
this.logger.error(error); | ||
throw new InternalServerErrorException('Failed to fetch featured data'); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { initContract } from '@ts-rest/core'; | ||
import { getAPIVersionAsPath } from '../utils/versioned-path'; | ||
|
||
const contract = initContract(); | ||
|
||
export const apiHome = contract.router({ | ||
getAllFeaturedData: { | ||
method: 'GET', | ||
path: `${getAPIVersionAsPath('1')}/home/featured/all`, | ||
query: contract.query, | ||
responses: { | ||
200: contract.response<unknown>() | ||
}, | ||
summary: 'Get all featured members, projects, teams and events', | ||
} | ||
}); |
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