Skip to content

Commit

Permalink
Fix fetch (#80)
Browse files Browse the repository at this point in the history
* Fix Jest + node-fetch

* v1.6.5
  • Loading branch information
AverageHelper committed Jun 22, 2022
1 parent ae8325b commit 230f655
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 21 deletions.
5 changes: 4 additions & 1 deletion jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
{
"displayName": "src",
"clearMocks": true,
"preset": "ts-jest",
"preset": "ts-jest/presets/js-with-ts-esm",
"transformIgnorePatterns": [
"node_modules/(?!(data-uri-to-buffer|formdata-polyfill|fetch-blob|node-fetch|node:http)/)"
],
"setupFilesAfterEnv": ["jest-extended/all"],
"testEnvironment": "node",
"testPathIgnorePatterns": ["/node_modules/"],
Expand Down
127 changes: 118 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gamgee",
"version": "1.6.4",
"version": "1.6.5",
"description": "A Discord bot for managing a song request queue.",
"private": true,
"scripts": {
Expand Down Expand Up @@ -48,7 +48,7 @@
"dotenv": "^16.0.1",
"humanize-duration": "^3.27.2",
"lodash": "^4.17.21",
"node-fetch-cjs": "^3.2.6",
"node-fetch": "^3.2.6",
"node-persist": "^3.1.0",
"reflect-metadata": "^0.1.13",
"soundcloud-scraper": "^5.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/actions/getVideoDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { isString } from "../helpers/guards.js";
import { richErrorMessage } from "../helpers/richErrorMessage.js";
import { URL } from "url";
import { useLogger } from "../logger.js";
import fetch from "node-fetch-cjs";
import fetch from "node-fetch";
import SoundCloud from "soundcloud-scraper";
import urlMetadata from "../helpers/urlMetadata/index.js";
import ytdl from "ytdl-core";
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/getPonyFmTrackInfoFromId.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetch from "node-fetch-cjs";
import { VideoError } from "../errors/index.js";
import fetch from "node-fetch";
import { isObject, isString } from "./guards.js";
import { VideoError } from "../errors/index.js";

// Based on https://github.com/Poniverse/Pony.fm/blob/a1522f3cd73d849099e4a3d897656dc8c4795dd7/app/Http/Controllers/Api/V1/TracksController.php#L129
export interface PonyFmTrackAPIResponse {
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/githubMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { RequestInit } from "node-fetch-cjs";
import type { RequestInit } from "node-fetch";
import fetch from "node-fetch";
import { isBoolean, isNumber, isObject, isString, isUrlString } from "./guards.js";
import { URL } from "url";
import { useLogger } from "../logger.js";
import { isBoolean, isNumber, isObject, isString, isUrlString } from "./guards.js";
import fetch from "node-fetch-cjs";

export interface GitHubMetadata {
name: string;
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/urlMetadata/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Adapted from https://github.com/laurengarcia/url-metadata */

import type { Fields } from "./lib/metadataFields.js";
import type { RequestInit } from "node-fetch-cjs";
import type { RequestInit } from "node-fetch";
import type { URL } from "url";
import fetch from "node-fetch-cjs";
import fetch from "node-fetch";
import parse from "./lib/parse.js";
import timeoutSignal from "timeout-signal";

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"allowJs": false,
"allowJs": true,
"declaration": false,
"removeComments": true,
"sourceMap": true,
Expand Down

0 comments on commit 230f655

Please sign in to comment.