Skip to content
Merged

Dev #80

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
7 changes: 7 additions & 0 deletions astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ export default defineConfig({
context: "server",
access: "secret",
}),

// vercel.com/docs/cron-jobs/manage-cron-jobs?framework=other#securing-cron-jobs
/** token to secure the vercel cron job that updates all the upstream feeds. */
CRON_SECRET: envField.string({
context: "server",
access: "secret",
}),
},
},

Expand Down
2 changes: 1 addition & 1 deletion knip.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"ignoreDependencies": [""],
"ignoreFiles": ["src/features/feedProviders/providers/tta.ts"]
"ignoreFiles": ["src/features/feedAdapters/adapters/tta.ts"]
}
2 changes: 1 addition & 1 deletion notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// find new post types on scouting.org at https://www.scouting.org/wp-json/wp/v2/types
// find new/edited pages at https://www.scouting.org/wp-json/wp/v2/pages

//todo add podcast rss feed provider?
//todo add podcast rss feed adapter?

## periodicals

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"dependencies": {
"@astrojs/check": "^0.9.7",
"@astrojs/react": "^5.0.0",
"@astrojs/rss": "^4.0.17",
"@astrojs/sitemap": "^3.7.1",
"@astrojs/vercel": "^10.0.0",
"@fortawesome/fontawesome-svg-core": "^7.2.0",
Expand Down
21 changes: 0 additions & 21 deletions pnpm-lock.yaml

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

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FeedProvider } from "@/features/feedProviders/feedProvider";
import { FeedAdapter } from "@/features/feedAdapters/feedAdapters";
import { parseRssFeed } from "feedsmith";

export function RssProvider(opts: RssProviderOpts) {
export function RssAdapter(opts: RssAdapterOpts) {
const execute = async () => {
const response = await fetch(opts.feedUrl);
const xml = await response.text();
Expand Down Expand Up @@ -34,7 +34,7 @@ export function RssProvider(opts: RssProviderOpts) {
});
};

return new FeedProvider({
return new FeedAdapter({
type: {
id: "rss",
human: "RSS",
Expand All @@ -43,6 +43,6 @@ export function RssProvider(opts: RssProviderOpts) {
});
}

type RssProviderOpts = {
type RssAdapterOpts = {
feedUrl: string;
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { FeedProvider } from "@/features/feedProviders/feedProvider";
import { FeedAdapter } from "@/features/feedAdapters/feedAdapters";
import he from "he";

//todo fetch the full post history

export function TtaProvider() {
return new FeedProvider({
export function TtaAdapter() {
return new FeedAdapter({
type: {
id: "tta",
human: "Trail to Adventure (bespoke)",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { FeedProvider } from "@/features/feedProviders/feedProvider";
import { FeedAdapter } from "@/features/feedAdapters/feedAdapters";
import type { PostData } from "@/features/posts/post";
import he from "he";

export function WordpressApiProvider(opts: WordpressApiProviderOpts) {
export function WordpressApiAdapter(opts: WordpressApiAdapterOpts) {
const execute = async () => {
const page1 = await fetchPage(1, opts);

return page1.posts;
};

return new FeedProvider({
return new FeedAdapter({
type: {
id: "wordpressApi",
human: "Wordpress",
Expand All @@ -18,7 +18,7 @@ export function WordpressApiProvider(opts: WordpressApiProviderOpts) {
});
}

async function fetchPage(page: number, opts: WordpressApiProviderOpts) {
async function fetchPage(page: number, opts: WordpressApiAdapterOpts) {
console.log(`fetch page ${page} from ${opts.baseUrl}`);

const url = new URL(
Expand Down Expand Up @@ -51,7 +51,7 @@ async function fetchPage(page: number, opts: WordpressApiProviderOpts) {
};
}

type WordpressApiProviderOpts = {
type WordpressApiAdapterOpts = {
/** the base url of the wordpress site */
baseUrl: string;
/** return only posts which have this category id */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import type { PostData } from "@/features/posts/post";

export class FeedProvider {
export class FeedAdapter {
type: {
id: string;
human: string;
};

execute: () => Promise<PostData[]>;

constructor(opts: FeedProviderOpts) {
constructor(opts: FeedAdapterOpts) {
this.type = opts.type;
this.execute = opts.execute;
}
}

type FeedProviderOpts = {
/** metadata about the feed provider type */
type FeedAdapterOpts = {
/** metadata about the feed adapter type */
type: {
/** machine id for the type of provider (rss, wordpressApi, etc) */
/** machine id for the type of adapter (rss, wordpressApi, etc) */
id: string;
/** human-readable name for the type of feed provider (RSS, Wordpress API, etc) */
/** human-readable name for the type of feed adapter (RSS, Wordpress API, etc) */
human: string;
};

Expand Down
Loading
Loading