Skip to content

Commit

Permalink
some formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Jan 20, 2022
1 parent 6efb695 commit dcbcb74
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 66 deletions.
36 changes: 8 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"homepage": "https://github.com/naseif/more4less#readme",
"devDependencies": {
"@types/node": "^17.0.8",
"@types/node-fetch": "^3.0.3",
"prettier": "^2.5.1",
"tslint": "^6.1.3",
"typedoc": "^0.22.11",
Expand Down
4 changes: 2 additions & 2 deletions src/BL/PriceSearchEngines/AlternatePriceSearchEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { ISearchResult } from '../../Interfaces';
export class AlternatePriceSearchEngine extends SearchEngineBase {
/**
* Scrapes alternate.de for products based on your search query
* @param searchTerm
* @returns
* @param string searchTerm
* @returns ISearchResult[]
*/

async search(searchTerm: string): Promise<ISearchResult[]> {
Expand Down
8 changes: 7 additions & 1 deletion src/BL/PriceSearchEngines/ClevertronicPriceSearchEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { SearchEngineBase, SearchResult } from '..';
import { ISearchResult } from '../../Interfaces';

export class ClevertronicPriceSearchEngine extends SearchEngineBase {
async search(searchTerm: string): Promise<any> {
/**
* Scrapes clevertronic for products based on your search query
* @param string searchTerm
* @returns ISearchResult[]
*/

async search(searchTerm: string): Promise<ISearchResult[]> {
const baseUrl = 'https://www.clevertronic.de';
const $ = await this.requestWebsite(baseUrl + '/products?s=', searchTerm);

Expand Down
4 changes: 2 additions & 2 deletions src/BL/PriceSearchEngines/EbayPriceSearchEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const cheerio = require('cheerio');
export class EbayPriceSearchEngine extends SearchEngineBase {
/**
* Scrapes eBay for products based on your search query
* @param {string} searchTerm
* @returns {ISearchResult[]}
* @param string searchTerm
* @returns ISearchResult[]
*/

async search(searchTerm: string): Promise<ISearchResult[]> {
Expand Down
5 changes: 5 additions & 0 deletions src/BL/PriceSearchEngines/KauflandPriceSearchEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import { SearchEngineBase, SearchResult } from '..';
import { ISearchResult } from '../../Interfaces';

export class KauflandPriceSearchEngine extends SearchEngineBase {
/**
* Scrapes Kaufland for products based on your search query
* @param string searchTerm
* @returns ISearchResult[]
*/
async search(searchTerm: string): Promise<ISearchResult[]> {
const baseUrl = 'https://www.kaufland.de';
const $ = await this.requestWebsite(baseUrl + '/item/search/?search_value=', searchTerm);
Expand Down
4 changes: 2 additions & 2 deletions src/BL/PriceSearchEngines/MediaMarktPriceSearchEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const cheerio = require('cheerio');
export class MediaMarktPriceSearchEngine extends SearchEngineBase {
/**
* Scrapes MediaMarkt for products based on your search query
* @param {string} searchTerm
* @returns {ISearchResult[]}
* @param string searchTerm
* @returns ISearchResult[]
*/

async search(searchTerm: string): Promise<ISearchResult[]> {
Expand Down
4 changes: 2 additions & 2 deletions src/BL/PriceSearchEngines/OttoPriceSearchEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { ISearchResult } from '../../Interfaces';
export class OttoPriceSearchEngine extends SearchEngineBase {
/**
* Scrapes otto.de for products based on your search query
* @param searchTerm
* @returns
* @param string searchTerm
* @returns ISearchResult[]
*/

async search(searchTerm: string): Promise<ISearchResult[]> {
Expand Down
4 changes: 2 additions & 2 deletions src/BL/PriceSearchEngines/ProshopPriceSearchEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { ISearchResult } from '../../Interfaces';
export class ProshopPriceSearchEngine extends SearchEngineBase {
/**
* Scrapes Proshop.de for products based on your search query
* @param {string} searchTerm
* @returns {ISearchResult[]}
* @param string searchTerm
* @returns ISearchResult[]
*/

async search(searchTerm: string): Promise<ISearchResult[]> {
Expand Down
4 changes: 2 additions & 2 deletions src/BL/PriceSearchEngines/SaturnPriceSearchEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const cheerio = require('cheerio');
export class SaturnPriceSearchEngine extends SearchEngineBase {
/**
* Scrapes Saturn for products based on your search query
* @param {string} searchTerm
* @returns {ISearchResult[]}
* @param string searchTerm
* @returns ISearchResult[]
*/

async search(searchTerm: string): Promise<ISearchResult[]> {
Expand Down
56 changes: 32 additions & 24 deletions src/BL/PriceSearchEngines/SearchEngineList.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
import { ISearchEngine, ISearchResult } from '../../Interfaces/index';
import * as engines from "../index"
import * as engines from '../index';

/**
* Engine list to select from when initializing the Class instead
* Engine list to select from when initializing the Class instead
*/

export type TSearchEngine = "Alternate" | "Amazon" | "Clevertronic" | "Ebay" | "Kaufland" | "MediaMarkt" | "Otto" | "Proshop" | "Saturn";
export type TSearchEngine =
| 'Alternate'
| 'Amazon'
| 'Clevertronic'
| 'Ebay'
| 'Kaufland'
| 'MediaMarkt'
| 'Otto'
| 'Proshop'
| 'Saturn';

export class SearchEngineList implements ISearchEngine {
/**
* array of all search engines
*/
searchEngines: TSearchEngine | ISearchEngine[]
searchEngines: TSearchEngine | ISearchEngine[];

/**
* array of the search engines you wish to iterate through
Expand All @@ -31,38 +40,37 @@ export class SearchEngineList implements ISearchEngine {
async search(searchTerm: string): Promise<ISearchResult[]> {
let result: ISearchResult[] = [];

if (typeof this.searchEngines === "string") {
if (typeof this.searchEngines === 'string') {
switch (this.searchEngines) {
case "Alternate":
result = await new engines.AlternatePriceSearchEngine().search(searchTerm)
case 'Alternate':
result = await new engines.AlternatePriceSearchEngine().search(searchTerm);
break;
case "Amazon":
result = await new engines.AmazonPriceSearchEngine2().search(searchTerm)
case 'Amazon':
result = await new engines.AmazonPriceSearchEngine2().search(searchTerm);
break;
case "Clevertronic":
result = await new engines.ClevertronicPriceSearchEngine().search(searchTerm)
case 'Clevertronic':
result = await new engines.ClevertronicPriceSearchEngine().search(searchTerm);
break;
case "Ebay":
result = await new engines.EbayPriceSearchEngine().search(searchTerm)
case 'Ebay':
result = await new engines.EbayPriceSearchEngine().search(searchTerm);
break;
case "Kaufland":
result = await new engines.KauflandPriceSearchEngine().search(searchTerm)
case 'Kaufland':
result = await new engines.KauflandPriceSearchEngine().search(searchTerm);
break;
case "MediaMarkt":
result = await new engines.MediaMarktPriceSearchEngine().search(searchTerm)
case 'MediaMarkt':
result = await new engines.MediaMarktPriceSearchEngine().search(searchTerm);
break;
case "Otto":
result = await new engines.OttoPriceSearchEngine().search(searchTerm)
case 'Otto':
result = await new engines.OttoPriceSearchEngine().search(searchTerm);
break;

case "Proshop":
result = await new engines.ProshopPriceSearchEngine().search(searchTerm)
case 'Proshop':
result = await new engines.ProshopPriceSearchEngine().search(searchTerm);
break;

case "Saturn":
result = await new engines.SaturnPriceSearchEngine().search(searchTerm)
case 'Saturn':
result = await new engines.SaturnPriceSearchEngine().search(searchTerm);
break;

}
} else {
for (const engine of this.searchEngines) {
Expand Down

0 comments on commit dcbcb74

Please sign in to comment.