Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove default export off of run and just set export to run #239

Merged
merged 5 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 6.7.1

- Remove `default` export off of the `run` function and just set `export` to `run`.
- Updating dependencies

## 6.7.0

- Replace `validator` with internal version of `isUrl` so we have better control on how that works.
Expand Down
23 changes: 5 additions & 18 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* eslint-disable max-len, import/no-import-module-exports */
/* eslint-disable import/no-import-module-exports */
import setOptionsAndReturnOpenGraphResults from './lib/openGraphScraper';
import type {
ErrorResult,
OpenGraphScraperOptions,
OgObject,
SuccessResult,
} from './lib/types';

/**
Expand All @@ -20,7 +21,7 @@ import type {
* @param {string} options.url - URL of the site. (Required)
* @returns {Promise} Promise Object with the Open Graph results
*/
export default async function run(options: OpenGraphScraperOptions): Promise<ErrorResult | SuccessResult> {
async function run(options: OpenGraphScraperOptions): Promise<ErrorResult | SuccessResult> {
let results;
try {
results = await setOptionsAndReturnOpenGraphResults(options);
Expand Down Expand Up @@ -49,18 +50,4 @@ export default async function run(options: OpenGraphScraperOptions): Promise<Err
return returnSuccess;
}

module.exports = run;

export interface SuccessResult {
error: false;
html: string;
response: object;
result: OgObject;
}

export interface ErrorResult {
error: true;
html: undefined;
response: undefined;
result: OgObject;
}
export = run;
14 changes: 14 additions & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
/* eslint-disable max-len */
import type { RequestInit } from 'undici';

export interface SuccessResult {
error: false;
html: string;
response: object;
result: OgObject;
}

export interface ErrorResult {
error: true;
html: undefined;
response: undefined;
result: OgObject;
}

/**
* The options used by Open Graph Scraper
*
Expand Down
Loading
Loading