Add isWord check to domains
This commit is contained in:
@@ -16,9 +16,6 @@ export class IswordController {
|
||||
|
||||
@Post()
|
||||
areWords(@Body() body: AreWordsDto) {
|
||||
return body.reduce((acc, word) => {
|
||||
acc[word] = this.isWordService.isWord(word)
|
||||
return acc;
|
||||
}, {} as {[key: string]: boolean})
|
||||
return this.isWordService.areWords(body)
|
||||
}
|
||||
}
|
||||
|
@@ -12,4 +12,10 @@ export class IswordService {
|
||||
|
||||
isWord = (word: string) =>
|
||||
this.dictContents.includes(word)
|
||||
|
||||
areWords = (words: string[]): {[key: string]: boolean} =>
|
||||
words.reduce((acc, word) => {
|
||||
acc[word] = this.isWord(word)
|
||||
return acc
|
||||
}, {} as {[key: string]: boolean})
|
||||
}
|
||||
|
@@ -1,9 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ParkioService } from './parkio.service';
|
||||
import { ParkioController } from './parkio.controller';
|
||||
import { IswordService } from 'src/isword/isword.service';
|
||||
|
||||
@Module({
|
||||
providers: [ParkioService],
|
||||
providers: [ParkioService, IswordService],
|
||||
controllers: [ParkioController]
|
||||
})
|
||||
export class ParkioModule {}
|
||||
|
@@ -11,6 +11,7 @@ import {
|
||||
} from './types';
|
||||
import axios from 'axios';
|
||||
import { filter, map, pipe } from 'ramda';
|
||||
import { IswordService } from 'src/isword/isword.service';
|
||||
|
||||
const parkIoEndpoints = {
|
||||
domains: 'https://park.io/domains.json',
|
||||
@@ -22,6 +23,10 @@ const parkIoEndpoints = {
|
||||
|
||||
@Injectable()
|
||||
export class ParkioService {
|
||||
constructor(
|
||||
private readonly isWordService: IswordService
|
||||
) {}
|
||||
|
||||
fetchDomainsForTld = async (tld: ParkioTld) => {};
|
||||
|
||||
fetchAllDomains = async (limit: number = 10_000): Promise<ParsedDomain[]> => {
|
||||
@@ -75,6 +80,7 @@ export class ParkioService {
|
||||
date_registered: domain.date_registered
|
||||
? this.parseDate(domain.date_registered)
|
||||
: undefined,
|
||||
is_word: this.isWordService.isWord(domainName)
|
||||
};
|
||||
};
|
||||
|
||||
@@ -100,6 +106,7 @@ export class ParkioService {
|
||||
created: this.parseDate(auction.created),
|
||||
domain,
|
||||
domain_length: domain.length,
|
||||
is_word: this.isWordService.isWord(domain),
|
||||
tld,
|
||||
};
|
||||
};
|
||||
|
@@ -51,6 +51,7 @@ export interface ParsedAuction {
|
||||
price: number;
|
||||
close_date: Date;
|
||||
created: Date;
|
||||
is_word: boolean;
|
||||
}
|
||||
|
||||
export interface ParsedDomain {
|
||||
@@ -59,6 +60,7 @@ export interface ParsedDomain {
|
||||
domain_length: number
|
||||
name: string;
|
||||
tld: string;
|
||||
is_word: boolean;
|
||||
date_available?: Date;
|
||||
date_registered?: Date;
|
||||
}
|
||||
|
Reference in New Issue
Block a user