Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
Signed-off-by: Ayane Satomi <chinodesuuu@gmail.com>
  • Loading branch information
sr229 committed May 4, 2020
1 parent 1882767 commit f8ae66e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 59 deletions.
44 changes: 22 additions & 22 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,12 @@ import { createReadStream } from "fs";
import { Readable } from "stream";

import { SagiriClientError, SagiriServerError } from "./errors";
import { generateMask, resolveResult } from "./util";
import { Response, Result } from "./response";
import sites from "./sites";
import { generateMask, resolveResult } from "./util";

const log = debug("sagiri");

export interface Options {
results?: number;
mask?: number[];
excludeMask?: number[];
// getRatings?: boolean;
testMode?: boolean;
db?: number;
}

export interface SagiriResult {
url: string;
site: string;
index: number;
similarity: number;
thumbnail: string;
authorName: string;
authorUrl: string;
raw: Result;
}

type File = string | Buffer | Readable;

/**
Expand Down Expand Up @@ -151,5 +131,25 @@ const sagiri = (token: string, defaultOptions: Options = { results: 5 }) => {
};
};

export default sagiri;
module.exports = sagiri;
export interface Options {
results?: number;
mask?: number[];
excludeMask?: number[];
// getRatings?: boolean;
testMode?: boolean;
db?: number;
}

export interface SagiriResult {
url: string;
site: string;
index: number;
similarity: number;
thumbnail: string;
authorName: string;
authorUrl: string;
raw: Result;
}

export default sagiri;
56 changes: 28 additions & 28 deletions lib/response.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,10 @@
export interface Response {
header: Header;
results: Result[];
}

export interface Header {
account_type: string;
index: { [id: string]: HeaderIndex | undefined }; // do i wanna generic this to be id value?
long_limit: string;
long_remaining: number;
message?: string;
minimum_similarity: number;
query_image: string;
query_image_display: string;
results_requested: number;
results_returned: number;
search_depth: string;
short_limit: number;
short_remaining: number;
status: number;
user_id: string;
}

interface HeaderIndex {
id: number;
parent_id: number;
results: number;
status: number;
}

export interface Result {
data: ResultData;
header: ResultHeader;
}

interface ResultData {
ext_urls: string[];
title: string;
Expand Down Expand Up @@ -106,3 +78,31 @@ export type Indices =
| "34"
| "35"
| "36";

export interface Response {
header: Header;
results: Result[];
}

export interface Header {
account_type: string;
index: { [id: string]: HeaderIndex | undefined }; // do i wanna generic this to be id value?
long_limit: string;
long_remaining: number;
message?: string;
minimum_similarity: number;
query_image: string;
query_image_display: string;
results_requested: number;
results_returned: number;
search_depth: string;
short_limit: number;
short_remaining: number;
status: number;
user_id: string;
}

export interface Result {
data: ResultData;
header: ResultHeader;
}
18 changes: 9 additions & 9 deletions lib/sites.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
/* eslint-disable @typescript-eslint/camelcase */
import { Result } from "./response";

export interface SiteData {
name: string;
index: number;
urlMatcher: RegExp;
backupUrl(result: Result): string;
// getRating(body: string): boolean; we remove this?
// isNSFW: boolean
}

// #region Site data objects
const DoujinMangaLexicon: SiteData = {
name: "The Doujinshi & Manga Lexicon",
Expand Down Expand Up @@ -252,4 +243,13 @@ const sites: { [key: string]: SiteData | undefined } = {
"36": MangaUpdates,
};

export interface SiteData {
name: string;
index: number;
urlMatcher: RegExp;
backupUrl(result: Result): string;
// getRating(body: string): boolean; we remove this?
// isNSFW: boolean
}

export default sites;

0 comments on commit f8ae66e

Please sign in to comment.