-
Notifications
You must be signed in to change notification settings - Fork 572
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apply pipethrough to most pds routes
- Loading branch information
Showing
13 changed files
with
63 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.getActorFeeds({ | ||
auth: ctx.authVerifier.access, | ||
handler: async ({ auth, params }) => { | ||
const requester = auth.credentials.did | ||
const res = await ctx.appViewAgent.api.app.bsky.feed.getActorFeeds( | ||
return pipethrough( | ||
ctx.cfg.bskyAppView.url, | ||
'app.bsky.feed.getActorFeeds', | ||
params, | ||
await ctx.appviewAuthHeaders(requester), | ||
) | ||
return { | ||
encoding: 'application/json', | ||
body: res.data, | ||
} | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.getFeedGenerator({ | ||
auth: ctx.authVerifier.access, | ||
handler: async ({ params, auth }) => { | ||
const requester = auth.credentials.did | ||
const res = await ctx.appViewAgent.api.app.bsky.feed.getFeedGenerator( | ||
return pipethrough( | ||
ctx.cfg.bskyAppView.url, | ||
'app.bsky.feed.getFeedGenerator', | ||
params, | ||
await ctx.appviewAuthHeaders(requester), | ||
) | ||
return { | ||
encoding: 'application/json', | ||
body: res.data, | ||
} | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
import { Server } from '../../../../lexicon' | ||
import AppContext from '../../../../context' | ||
import { authPassthru } from '../../../proxy' | ||
import { pipethrough } from '../../../../pipethrough' | ||
|
||
export default function (server: Server, ctx: AppContext) { | ||
server.app.bsky.graph.getFollows({ | ||
auth: ctx.authVerifier.accessOrRole, | ||
handler: async ({ req, params, auth }) => { | ||
const requester = | ||
auth.credentials.type === 'access' ? auth.credentials.did : null | ||
const res = await ctx.appViewAgent.api.app.bsky.graph.getFollows( | ||
return pipethrough( | ||
ctx.cfg.bskyAppView.url, | ||
'app.bsky.graph.getFollows', | ||
params, | ||
requester ? await ctx.appviewAuthHeaders(requester) : authPassthru(req), | ||
) | ||
return { | ||
encoding: 'application/json', | ||
body: res.data, | ||
} | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.graph.getList({ | ||
auth: ctx.authVerifier.access, | ||
handler: async ({ params, auth }) => { | ||
const requester = auth.credentials.did | ||
const res = await ctx.appViewAgent.api.app.bsky.graph.getList( | ||
return pipethrough( | ||
ctx.cfg.bskyAppView.url, | ||
'app.bsky.graph.getList', | ||
params, | ||
await ctx.appviewAuthHeaders(requester), | ||
) | ||
return { | ||
encoding: 'application/json', | ||
body: res.data, | ||
} | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.graph.getListBlocks({ | ||
auth: ctx.authVerifier.access, | ||
handler: async ({ auth, params }) => { | ||
const requester = auth.credentials.did | ||
const res = await ctx.appViewAgent.api.app.bsky.graph.getListBlocks( | ||
return pipethrough( | ||
ctx.cfg.bskyAppView.url, | ||
'app.bsky.graph.getListBlocks', | ||
params, | ||
await ctx.appviewAuthHeaders(requester), | ||
) | ||
return { | ||
encoding: 'application/json', | ||
body: res.data, | ||
} | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.graph.getListMutes({ | ||
auth: ctx.authVerifier.access, | ||
handler: async ({ params, auth }) => { | ||
const requester = auth.credentials.did | ||
const res = await ctx.appViewAgent.api.app.bsky.graph.getListMutes( | ||
return pipethrough( | ||
ctx.cfg.bskyAppView.url, | ||
'app.bsky.graph.getListMutes', | ||
params, | ||
await ctx.appviewAuthHeaders(requester), | ||
) | ||
return { | ||
encoding: 'application/json', | ||
body: res.data, | ||
} | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.graph.getLists({ | ||
auth: ctx.authVerifier.access, | ||
handler: async ({ params, auth }) => { | ||
const requester = auth.credentials.did | ||
const res = await ctx.appViewAgent.api.app.bsky.graph.getLists( | ||
return pipethrough( | ||
ctx.cfg.bskyAppView.url, | ||
'app.bsky.graph.getLists', | ||
params, | ||
await ctx.appviewAuthHeaders(requester), | ||
) | ||
return { | ||
encoding: 'application/json', | ||
body: res.data, | ||
} | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.graph.getMutes({ | ||
auth: ctx.authVerifier.access, | ||
handler: async ({ auth, params }) => { | ||
const requester = auth.credentials.did | ||
const res = await ctx.appViewAgent.api.app.bsky.graph.getMutes( | ||
return pipethrough( | ||
ctx.cfg.bskyAppView.url, | ||
'app.bsky.graph.getMutes', | ||
params, | ||
await ctx.appviewAuthHeaders(requester), | ||
) | ||
return { | ||
encoding: 'application/json', | ||
body: res.data, | ||
} | ||
}, | ||
}) | ||
} |
16 changes: 7 additions & 9 deletions
16
packages/pds/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.graph.getSuggestedFollowsByActor({ | ||
auth: ctx.authVerifier.access, | ||
handler: async ({ auth, params }) => { | ||
const requester = auth.credentials.did | ||
const res = | ||
await ctx.appViewAgent.api.app.bsky.graph.getSuggestedFollowsByActor( | ||
params, | ||
await ctx.appviewAuthHeaders(requester), | ||
) | ||
return { | ||
encoding: 'application/json', | ||
body: res.data, | ||
} | ||
return pipethrough( | ||
ctx.cfg.bskyAppView.url, | ||
'app.bsky.graph.getSuggestedFollowsByActor', | ||
params, | ||
await ctx.appviewAuthHeaders(requester), | ||
) | ||
}, | ||
}) | ||
} |
16 changes: 7 additions & 9 deletions
16
packages/pds/src/api/app/bsky/notification/getUnreadCount.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.notification.getUnreadCount({ | ||
auth: ctx.authVerifier.access, | ||
handler: async ({ auth, params }) => { | ||
const requester = auth.credentials.did | ||
const res = | ||
await ctx.appViewAgent.api.app.bsky.notification.getUnreadCount( | ||
params, | ||
await ctx.appviewAuthHeaders(requester), | ||
) | ||
return { | ||
encoding: 'application/json', | ||
body: res.data, | ||
} | ||
return pipethrough( | ||
ctx.cfg.bskyAppView.url, | ||
'app.bsky.notification.getUnreadCount', | ||
params, | ||
await ctx.appviewAuthHeaders(requester), | ||
) | ||
}, | ||
}) | ||
} |
16 changes: 7 additions & 9 deletions
16
packages/pds/src/api/app/bsky/notification/listNotifications.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.notification.listNotifications({ | ||
auth: ctx.authVerifier.access, | ||
handler: async ({ params, auth }) => { | ||
const requester = auth.credentials.did | ||
const res = | ||
await ctx.appViewAgent.api.app.bsky.notification.listNotifications( | ||
params, | ||
await ctx.appviewAuthHeaders(requester), | ||
) | ||
return { | ||
encoding: 'application/json', | ||
body: res.data, | ||
} | ||
return pipethrough( | ||
ctx.cfg.bskyAppView.url, | ||
'app.bsky.notification.listNotifications', | ||
params, | ||
await ctx.appviewAuthHeaders(requester), | ||
) | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters