1- import { Controller , Get , NotFoundError , Param } from "routing-controllers" ;
1+ import { Controller , Get , NotFoundError , Param , QueryParams } from "routing-controllers" ;
22import { Service } from "typedi" ;
33
44import { ContributorRepository } from "./repository" ;
@@ -10,7 +10,7 @@ import {
1010} from "./types" ;
1111import { ProjectRepository } from "src/project/repository" ;
1212import { ContributionRepository } from "src/contribution/repository" ;
13- import { Language } from "@dzcode.io/utils/dist /language" ;
13+ import { LanguageQuery } from "src/_utils /language" ;
1414
1515@Service ( )
1616@Controller ( "/contributors" )
@@ -22,9 +22,9 @@ export class ContributorController {
2222 ) { }
2323
2424 @Get ( "/" )
25- public async getContributors ( ) : Promise < GetContributorsResponse > {
26- // todo: lang query param
27- const lang : Language = "en" ;
25+ public async getContributors (
26+ @ QueryParams ( ) { lang } : LanguageQuery ,
27+ ) : Promise < GetContributorsResponse > {
2828 const contributors = await this . contributorRepository . findForList ( lang ) ;
2929
3030 return {
@@ -42,10 +42,10 @@ export class ContributorController {
4242 }
4343
4444 @Get ( "/:id" )
45- public async getContributor ( @ Param ( "id" ) id : string ) : Promise < GetContributorResponse > {
46- // todo: lang query param
47- const lang : Language = "en" ;
48-
45+ public async getContributor (
46+ @ Param ( "id" ) id : string ,
47+ @ QueryParams ( ) { lang } : LanguageQuery ,
48+ ) : Promise < GetContributorResponse > {
4949 const [ contributor , projects , contributions ] = await Promise . all ( [
5050 this . contributorRepository . findWithStats ( id , lang ) ,
5151 this . projectRepository . findForContributor ( id ) ,
@@ -64,10 +64,10 @@ export class ContributorController {
6464 }
6565
6666 @Get ( "/:id/name" )
67- public async getContributorName ( @ Param ( "id" ) id : string ) : Promise < GetContributorNameResponse > {
68- // todo: lang query param
69- const lang : Language = "en" ;
70-
67+ public async getContributorName (
68+ @ Param ( "id" ) id : string ,
69+ @ QueryParams ( ) { lang } : LanguageQuery ,
70+ ) : Promise < GetContributorNameResponse > {
7171 const contributor = await this . contributorRepository . findName ( id , lang ) ;
7272
7373 if ( ! contributor ) throw new NotFoundError ( "Contributor not found" ) ;
0 commit comments