Skip to content

Commit

Permalink
refactor: better type defintions (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats authored Nov 5, 2023
1 parent 55b1ce9 commit 5260fe7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ coverage
stats.html
examples
src/node.mjs
lightweight
lightweight/index.js
10 changes: 6 additions & 4 deletions lightweight/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type ScreenshotOptions = {
overlay?: ScreenshotOverlay
}

export type MqlOptions = {
type MqlClientOptions = {
endpoint?: string;
apiKey?: string;
retry?: number;
Expand All @@ -54,7 +54,7 @@ type MqlQueryOptions = {
type?: "audio" | "author" | "auto" | "boolean" | "date" | "description" | "email" | "image" | "ip" | "lang" | "logo" | "number" | "object" | "publisher" | "regexp" | "string" | "title" | "url" | "video";
}

export type MicrolinkApiOptions = {
type MicrolinkApiOptions = {
adblock?: boolean;
animations?: boolean;
audio?: boolean;
Expand Down Expand Up @@ -152,7 +152,7 @@ export type MqlPayload = {
headers: { [key: string]: string };
}

export type MqlResponse = MqlPayload & {
type MqlResponse = MqlPayload & {
response: {
url: string;
statusCode: number;
Expand All @@ -174,9 +174,11 @@ export type MqlError = {
url: string;
}

export type MqlOptions = MqlClientOptions & MicrolinkApiOptions;

declare function mql(
url: string,
opts?: MqlOptions & MicrolinkApiOptions,
opts?: MqlOptions,
gotOpts?: object
): Promise<MqlResponse>;

Expand Down
6 changes: 3 additions & 3 deletions src/node.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MqlPayload, MqlOptions, MicrolinkApiOptions } from '../lightweight'
import { MqlPayload, MqlOptions } from '../lightweight'

export { MqlError, MqlPayload } from '../lightweight'

Expand All @@ -14,14 +14,14 @@ export type MqlResponse = MqlPayload & {

declare function mql(
url: string,
opts?: MqlOptions & MicrolinkApiOptions,
opts?: MqlOptions,
gotOpts?: object
): Promise<MqlResponse>;

declare namespace mql {
function stream(
url: string,
opts?: MqlOptions & MicrolinkApiOptions,
opts?: MqlOptions,
gotOpts?: object
): NodeJS.ReadableStream;
}
Expand Down

1 comment on commit 5260fe7

@vercel
Copy link

@vercel vercel bot commented on 5260fe7 Nov 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.