Add names api

This commit is contained in:
2025-01-13 21:56:53 -07:00
parent 368f2b100f
commit 76f093eeda
4 changed files with 79 additions and 0 deletions

View 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),
},
};
}
}