Skip to content

Commit 6563450

Browse files
chore: added property to goodreads feed
* feat: updated getSubstackFeedByLink method signature now returns raw XML string when no callback is passed * 1.0.3 * fix: updated declaration file * 1.0.4 * fix: updated declaration * 1.0.5 * fix: updated parsing for non browser calls - updated non browser calls - added jest config and test * 1.0.6 * fix: updated parsing for non browser calls * 1.0.7 * fix: determine client or server call * 1.0.8 * chore: fixed error in package.json * 1.0.9 * chore: fixed build issues * 1.0.10 * fix: fixed issues with client and server fetching * 1.0.11 * chore: removed .tgz * 1.0.12 * Pre-version bump changes * 1.0.13 * chore: cleanup removed logs * 1.0.14 * chore: updated types * 1.1.1 * chore: added property to goodreads feed added book_large_image_url to goodreads feed * 1.1.2 --------- Co-authored-by: GitHub Actions <actions@github.com>
1 parent adc5fc1 commit 6563450

5 files changed

Lines changed: 11 additions & 8 deletions

File tree

lib/main.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
SubstackItem,
1818
} from "./types";
1919

20-
const CORS_PROXY = "https://api.allorigins.win/get?url=";
20+
const CORS_PROXY = "https://www.whateverorigin.org/get?url=";
2121
const isBrowser = typeof document !== "undefined";
2222

2323
// Internal API
@@ -95,16 +95,16 @@ const transformRawGoodreadsItem = (item: RawGoodreadsItem): GoodreadsItem => {
9595
return {
9696
title: item.title[0],
9797
link: item.link[0],
98-
book_image_url: item["book_image_url"][0],
98+
book_image_url: item["book_large_image_url"][0],
9999
author_name: item["author_name"][0],
100100
book_description: item["book_description"][0],
101101
};
102102
};
103103
// Internal API
104-
const getRawXMLGoodreadsFeed = async (feedUrl: string) => {
104+
const getRawXMLGoodreadsFeed = async (feedUrl: string, proxy?: string) => {
105105
try {
106106
const path = isBrowser
107-
? `${CORS_PROXY}${encodeURIComponent(feedUrl)}`
107+
? `${proxy ?? CORS_PROXY}${encodeURIComponent(feedUrl)}`
108108
: feedUrl;
109109
const promise = await fetch(path);
110110
if (promise.ok) return isBrowser ? promise.json() : promise.text();
@@ -118,8 +118,9 @@ export const getGoodreadsFeed = async (
118118
feedUrl: string,
119119
/* eslint-disable @typescript-eslint/no-explicit-any */
120120
callback?: (err: Error | null, result: unknown) => void,
121+
proxy?: string,
121122
): Promise<unknown> => {
122-
const rawXML = await getRawXMLGoodreadsFeed(feedUrl);
123+
const rawXML = await getRawXMLGoodreadsFeed(feedUrl, proxy);
123124
// NOTE: server side call
124125
if (!isBrowser) {
125126
return parseXML(rawXML, callback);

lib/typeguards.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ export const isRawGoodreadsItem = (item: unknown): item is RawGoodreadsItem => {
202202
item.hasOwnProperty("title") &&
203203
item.hasOwnProperty("link") &&
204204
item.hasOwnProperty("book_image_url") &&
205+
item.hasOwnProperty("book_large_image_url") &&
205206
item.hasOwnProperty("author_name") &&
206207
item.hasOwnProperty("book_description")
207208
);

lib/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export type RawGoodreadsItem = {
105105
title: string[];
106106
link: string[];
107107
book_image_url: string[];
108+
book_large_image_url: string[];
108109
author_name: string[];
109110
book_description: string[];
110111
[key: string]: unknown;

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "substack-feed-api",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"type": "module",
55
"files": [
66
"dist",

0 commit comments

Comments
 (0)