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