Skip to content

Commit

Permalink
Issue #213: Add user agent
Browse files Browse the repository at this point in the history
  • Loading branch information
dellagustin committed Feb 5, 2023
1 parent 094393d commit 2f826a7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ const express = require('express')
const app = express() // create express app
const { makeThreadcap, InMemoryCache, updateThreadcap, makeRateLimitedFetcher } = require('threadcap');
const fetch = require('node-fetch');
const packageJson = require('../package.json');

// Gets the .env variables
require('dotenv').config()

const USER_AGENT = `Podcastindex.org-web/${packageJson.version}`;

// Utilizing the node repo from comster/podcast-index-api :)
// NOTE: This server will work as a reverse proxy.
const api = require('podcast-index-api')(
Expand Down Expand Up @@ -106,6 +109,17 @@ app.use('/api/episodes/byfeedid', async (req, res) => {
let feedId = req.query.id
let max = req.query.max
const response = await api.episodesByFeedId(feedId, null, max)

// Inject fake socialInteract content here for testing
// it does not even have to be valid data, the comments API fetches it again
// based on the episode ID
response.items.forEach((item) => {
item.socialInteracts = [{
uri: 'https://podcastindex.social/users/dave/statuses/109683341113064081',
protocol: 'activitypub',
}]
})

res.send(response)
})

Expand All @@ -127,7 +141,7 @@ app.use('/api/comments/byepisodeid', async (req, res) => {
// later when the response is actually used
console.log(response)

const userAgent = 'podcastindex.org server';
const userAgent = USER_AGENT;
const cache = new InMemoryCache();
const fetcher = makeRateLimitedFetcher(fetch);

Expand Down

0 comments on commit 2f826a7

Please sign in to comment.