Add names api
This commit is contained in:
26
src/names/names.controller.ts
Normal file
26
src/names/names.controller.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Controller, Get, Param } from '@nestjs/common';
|
||||
import { NamesService } from './names.service';
|
||||
|
||||
@Controller('names')
|
||||
export class NamesController {
|
||||
constructor(private readonly namesService: NamesService) {}
|
||||
|
||||
@Get()
|
||||
async getNameList() {
|
||||
return await this.namesService.getNameList();
|
||||
}
|
||||
|
||||
@Get(':name')
|
||||
async getNameInformation(@Param('name') name: string) {
|
||||
return {
|
||||
popularity: await this.namesService.getSsaNameData(name),
|
||||
otherSites: {
|
||||
behindTheName: `https://www.behindthename.com/name/${name.toLocaleLowerCase()}`,
|
||||
babynames: `https://www.babynames.com/name/${name.toLocaleLowerCase()}`,
|
||||
},
|
||||
behindTheName: {
|
||||
synonyms: await this.namesService.getBtnSynonyms(name),
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user