From 56c9879081d0f1cc8d676fecf6623f26ce087d01 Mon Sep 17 00:00:00 2001 From: Devin Ivy Date: Wed, 7 Feb 2024 16:49:34 -0500 Subject: [PATCH] apply pipethrough to remaining pds routes --- .../pds/src/api/app/bsky/actor/getSuggestions.ts | 9 ++++----- .../api/app/bsky/actor/searchActorsTypeahead.ts | 16 +++++++--------- .../src/api/app/bsky/feed/getFeedGenerators.ts | 9 ++++----- packages/pds/src/api/app/bsky/feed/getLikes.ts | 9 ++++----- .../pds/src/api/app/bsky/feed/getListFeed.ts | 9 ++++----- packages/pds/src/api/app/bsky/feed/getPosts.ts | 9 ++++----- .../pds/src/api/app/bsky/feed/getRepostedBy.ts | 9 ++++----- .../src/api/app/bsky/feed/getSuggestedFeeds.ts | 9 ++++----- .../pds/src/api/app/bsky/feed/searchPosts.ts | 9 ++++----- .../bsky/unspecced/getPopularFeedGenerators.ts | 16 +++++++--------- .../app/bsky/unspecced/getTaggedSuggestions.ts | 16 +++++++--------- 11 files changed, 53 insertions(+), 67 deletions(-) diff --git a/packages/pds/src/api/app/bsky/actor/getSuggestions.ts b/packages/pds/src/api/app/bsky/actor/getSuggestions.ts index 5fd8b260276..74d69aee453 100644 --- a/packages/pds/src/api/app/bsky/actor/getSuggestions.ts +++ b/packages/pds/src/api/app/bsky/actor/getSuggestions.ts @@ -1,19 +1,18 @@ import { Server } from '../../../../lexicon' import AppContext from '../../../../context' +import { pipethrough } from '../../../../pipethrough' export default function (server: Server, ctx: AppContext) { server.app.bsky.actor.getSuggestions({ auth: ctx.authVerifier.access, handler: async ({ params, auth }) => { const requester = auth.credentials.did - const res = await ctx.appViewAgent.api.app.bsky.actor.getSuggestions( + return pipethrough( + ctx.cfg.bskyAppView.url, + 'app.bsky.feed.getSuggestions', params, await ctx.appviewAuthHeaders(requester), ) - return { - encoding: 'application/json', - body: res.data, - } }, }) } diff --git a/packages/pds/src/api/app/bsky/actor/searchActorsTypeahead.ts b/packages/pds/src/api/app/bsky/actor/searchActorsTypeahead.ts index c1a8738488d..d3354312883 100644 --- a/packages/pds/src/api/app/bsky/actor/searchActorsTypeahead.ts +++ b/packages/pds/src/api/app/bsky/actor/searchActorsTypeahead.ts @@ -1,20 +1,18 @@ import { Server } from '../../../../lexicon' import AppContext from '../../../../context' +import { pipethrough } from '../../../../pipethrough' export default function (server: Server, ctx: AppContext) { server.app.bsky.actor.searchActorsTypeahead({ auth: ctx.authVerifier.access, handler: async ({ params, auth }) => { const requester = auth.credentials.did - const res = - await ctx.appViewAgent.api.app.bsky.actor.searchActorsTypeahead( - params, - await ctx.appviewAuthHeaders(requester), - ) - return { - encoding: 'application/json', - body: res.data, - } + return pipethrough( + ctx.cfg.bskyAppView.url, + 'app.bsky.feed.searchActorsTypeahead', + params, + await ctx.appviewAuthHeaders(requester), + ) }, }) } diff --git a/packages/pds/src/api/app/bsky/feed/getFeedGenerators.ts b/packages/pds/src/api/app/bsky/feed/getFeedGenerators.ts index 1370fbbd6f3..12755d0feea 100644 --- a/packages/pds/src/api/app/bsky/feed/getFeedGenerators.ts +++ b/packages/pds/src/api/app/bsky/feed/getFeedGenerators.ts @@ -1,19 +1,18 @@ import { Server } from '../../../../lexicon' import AppContext from '../../../../context' +import { pipethrough } from '../../../../pipethrough' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getFeedGenerators({ auth: ctx.authVerifier.access, handler: async ({ params, auth }) => { const requester = auth.credentials.did - const res = await ctx.appViewAgent.api.app.bsky.feed.getFeedGenerators( + return pipethrough( + ctx.cfg.bskyAppView.url, + 'app.bsky.feed.getFeedGenerators', params, await ctx.appviewAuthHeaders(requester), ) - return { - encoding: 'application/json', - body: res.data, - } }, }) } diff --git a/packages/pds/src/api/app/bsky/feed/getLikes.ts b/packages/pds/src/api/app/bsky/feed/getLikes.ts index ad656dfbd4c..cb5f2cd6fbc 100644 --- a/packages/pds/src/api/app/bsky/feed/getLikes.ts +++ b/packages/pds/src/api/app/bsky/feed/getLikes.ts @@ -1,19 +1,18 @@ import { Server } from '../../../../lexicon' import AppContext from '../../../../context' +import { pipethrough } from '../../../../pipethrough' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getLikes({ auth: ctx.authVerifier.access, handler: async ({ params, auth }) => { const requester = auth.credentials.did - const res = await ctx.appViewAgent.api.app.bsky.feed.getLikes( + return pipethrough( + ctx.cfg.bskyAppView.url, + 'app.bsky.feed.getLikes', params, await ctx.appviewAuthHeaders(requester), ) - return { - encoding: 'application/json', - body: res.data, - } }, }) } diff --git a/packages/pds/src/api/app/bsky/feed/getListFeed.ts b/packages/pds/src/api/app/bsky/feed/getListFeed.ts index 06e2abcbfe5..cbbc757dd52 100644 --- a/packages/pds/src/api/app/bsky/feed/getListFeed.ts +++ b/packages/pds/src/api/app/bsky/feed/getListFeed.ts @@ -1,19 +1,18 @@ import { Server } from '../../../../lexicon' import AppContext from '../../../../context' +import { pipethrough } from '../../../../pipethrough' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getListFeed({ auth: ctx.authVerifier.access, handler: async ({ auth, params }) => { const requester = auth.credentials.did - const res = await ctx.appViewAgent.api.app.bsky.feed.getListFeed( + return pipethrough( + ctx.cfg.bskyAppView.url, + 'app.bsky.feed.getListFeed', params, await ctx.appviewAuthHeaders(requester), ) - return { - encoding: 'application/json', - body: res.data, - } }, }) } diff --git a/packages/pds/src/api/app/bsky/feed/getPosts.ts b/packages/pds/src/api/app/bsky/feed/getPosts.ts index f04927a4997..5caa986f9f4 100644 --- a/packages/pds/src/api/app/bsky/feed/getPosts.ts +++ b/packages/pds/src/api/app/bsky/feed/getPosts.ts @@ -1,19 +1,18 @@ import { Server } from '../../../../lexicon' import AppContext from '../../../../context' +import { pipethrough } from '../../../../pipethrough' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getPosts({ auth: ctx.authVerifier.access, handler: async ({ params, auth }) => { const requester = auth.credentials.did - const res = await ctx.appViewAgent.api.app.bsky.feed.getPosts( + return pipethrough( + ctx.cfg.bskyAppView.url, + 'app.bsky.feed.getPosts', params, await ctx.appviewAuthHeaders(requester), ) - return { - encoding: 'application/json', - body: res.data, - } }, }) } diff --git a/packages/pds/src/api/app/bsky/feed/getRepostedBy.ts b/packages/pds/src/api/app/bsky/feed/getRepostedBy.ts index e797967fc2a..dcb00d5ce64 100644 --- a/packages/pds/src/api/app/bsky/feed/getRepostedBy.ts +++ b/packages/pds/src/api/app/bsky/feed/getRepostedBy.ts @@ -1,19 +1,18 @@ import { Server } from '../../../../lexicon' import AppContext from '../../../../context' +import { pipethrough } from '../../../../pipethrough' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getRepostedBy({ auth: ctx.authVerifier.access, handler: async ({ params, auth }) => { const requester = auth.credentials.did - const res = await ctx.appViewAgent.api.app.bsky.feed.getRepostedBy( + return pipethrough( + ctx.cfg.bskyAppView.url, + 'app.bsky.feed.getRepostedBy', params, await ctx.appviewAuthHeaders(requester), ) - return { - encoding: 'application/json', - body: res.data, - } }, }) } diff --git a/packages/pds/src/api/app/bsky/feed/getSuggestedFeeds.ts b/packages/pds/src/api/app/bsky/feed/getSuggestedFeeds.ts index 17fbf947471..ee1161ca0ff 100644 --- a/packages/pds/src/api/app/bsky/feed/getSuggestedFeeds.ts +++ b/packages/pds/src/api/app/bsky/feed/getSuggestedFeeds.ts @@ -1,19 +1,18 @@ import { Server } from '../../../../lexicon' import AppContext from '../../../../context' +import { pipethrough } from '../../../../pipethrough' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getSuggestedFeeds({ auth: ctx.authVerifier.access, handler: async ({ auth, params }) => { const requester = auth.credentials.did - const res = await ctx.appViewAgent.api.app.bsky.feed.getSuggestedFeeds( + return pipethrough( + ctx.cfg.bskyAppView.url, + 'app.bsky.feed.getSuggestedFeeds', params, await ctx.appviewAuthHeaders(requester), ) - return { - encoding: 'application/json', - body: res.data, - } }, }) } diff --git a/packages/pds/src/api/app/bsky/feed/searchPosts.ts b/packages/pds/src/api/app/bsky/feed/searchPosts.ts index e9942432fde..24bc33f6034 100644 --- a/packages/pds/src/api/app/bsky/feed/searchPosts.ts +++ b/packages/pds/src/api/app/bsky/feed/searchPosts.ts @@ -1,19 +1,18 @@ import { Server } from '../../../../lexicon' import AppContext from '../../../../context' +import { pipethrough } from '../../../../pipethrough' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.searchPosts({ auth: ctx.authVerifier.access, handler: async ({ params, auth }) => { const requester = auth.credentials.did - const res = await ctx.appViewAgent.api.app.bsky.feed.searchPosts( + return pipethrough( + ctx.cfg.bskyAppView.url, + 'app.bsky.feed.searchPosts', params, await ctx.appviewAuthHeaders(requester), ) - return { - encoding: 'application/json', - body: res.data, - } }, }) } diff --git a/packages/pds/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts b/packages/pds/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts index 08466ed9f5c..56f0c6134af 100644 --- a/packages/pds/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts +++ b/packages/pds/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts @@ -1,5 +1,6 @@ import { Server } from '../../../../lexicon' import AppContext from '../../../../context' +import { pipethrough } from '../../../../pipethrough' // THIS IS A TEMPORARY UNSPECCED ROUTE export default function (server: Server, ctx: AppContext) { @@ -7,15 +8,12 @@ export default function (server: Server, ctx: AppContext) { auth: ctx.authVerifier.access, handler: async ({ auth, params }) => { const requester = auth.credentials.did - const res = - await ctx.appViewAgent.api.app.bsky.unspecced.getPopularFeedGenerators( - params, - await ctx.appviewAuthHeaders(requester), - ) - return { - encoding: 'application/json', - body: res.data, - } + return pipethrough( + ctx.cfg.bskyAppView.url, + 'app.bsky.unspecced.getPopularFeedGenerators', + params, + await ctx.appviewAuthHeaders(requester), + ) }, }) } diff --git a/packages/pds/src/api/app/bsky/unspecced/getTaggedSuggestions.ts b/packages/pds/src/api/app/bsky/unspecced/getTaggedSuggestions.ts index cd43177b83d..80c868490c4 100644 --- a/packages/pds/src/api/app/bsky/unspecced/getTaggedSuggestions.ts +++ b/packages/pds/src/api/app/bsky/unspecced/getTaggedSuggestions.ts @@ -1,5 +1,6 @@ import { Server } from '../../../../lexicon' import AppContext from '../../../../context' +import { pipethrough } from '../../../../pipethrough' // THIS IS A TEMPORARY UNSPECCED ROUTE export default function (server: Server, ctx: AppContext) { @@ -7,15 +8,12 @@ export default function (server: Server, ctx: AppContext) { auth: ctx.authVerifier.access, handler: async ({ auth, params }) => { const requester = auth.credentials.did - const res = - await ctx.appViewAgent.api.app.bsky.unspecced.getTaggedSuggestions( - params, - await ctx.appviewAuthHeaders(requester), - ) - return { - encoding: 'application/json', - body: res.data, - } + return pipethrough( + ctx.cfg.bskyAppView.url, + 'app.bsky.unspecced.getTaggedSuggestions', + params, + await ctx.appviewAuthHeaders(requester), + ) }, }) }