42 lines
995 B
TypeScript
42 lines
995 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { MinioService } from 'src/minio/minio.service';
|
|
|
|
@Injectable()
|
|
export class NamesService {
|
|
constructor(private readonly minioService: MinioService) {}
|
|
|
|
async getNameList(): Promise<string[]> {
|
|
return JSON.parse(
|
|
(
|
|
await this.minioService.getCachedBuffer(
|
|
'cdn-source',
|
|
'baby-name-data/list.json',
|
|
)
|
|
).toString(),
|
|
);
|
|
}
|
|
|
|
async getSsaNameData(name: string): Promise<any> {
|
|
return JSON.parse(
|
|
(
|
|
await this.minioService.getCachedBuffer(
|
|
'cdn-source',
|
|
`baby-name-data/individual/${name}.json`,
|
|
)
|
|
).toString(),
|
|
);
|
|
}
|
|
|
|
async getBtnSynonyms(name: string): Promise<string[]> {
|
|
const synonymData = JSON.parse(
|
|
(
|
|
await this.minioService.getCachedBuffer(
|
|
'cdn-source',
|
|
`baby-name-data/btn_synonyms.json`,
|
|
)
|
|
).toString(),
|
|
);
|
|
return synonymData[name]?.synonyms || [];
|
|
}
|
|
}
|