From 5b06d07422081e7cff38f48ce0fef9fa9c2c9f15 Mon Sep 17 00:00:00 2001 From: Daniel Holmgren Date: Tue, 26 Sep 2023 11:10:20 -0500 Subject: [PATCH] Refactor PDS appview routes (#1673) move routes around --- .../api/app/bsky/actor/getProfile.ts | 10 +-- .../api/app/bsky/actor/getProfiles.ts | 8 +- .../api/app/bsky/actor/getSuggestions.ts | 4 +- packages/pds/src/api/app/bsky/actor/index.ts | 10 +++ .../api/app/bsky/actor/searchActors.ts | 4 +- .../app/bsky/actor/searchActorsTypeahead.ts | 4 +- .../api/app/bsky/feed/getActorFeeds.ts | 4 +- .../api/app/bsky/feed/getActorLikes.ts | 10 +-- .../api/app/bsky/feed/getAuthorFeed.ts | 12 +-- .../api/app/bsky/feed/getFeed.ts | 4 +- .../api/app/bsky/feed/getFeedGenerator.ts | 4 +- .../api/app/bsky/feed/getFeedGenerators.ts | 4 +- .../api/app/bsky/feed/getLikes.ts | 4 +- .../api/app/bsky/feed/getListFeed.ts | 4 +- .../api/app/bsky/feed/getPostThread.ts | 12 +-- .../api/app/bsky/feed/getPosts.ts | 4 +- .../api/app/bsky/feed/getRepostedBy.ts | 4 +- .../api/app/bsky/feed/getSuggestedFeeds.ts | 4 +- .../api/app/bsky/feed/getTimeline.ts | 8 +- packages/pds/src/api/app/bsky/feed/index.ts | 31 ++++++++ .../api/app/bsky/graph/getBlocks.ts | 4 +- .../api/app/bsky/graph/getFollowers.ts | 6 +- .../api/app/bsky/graph/getFollows.ts | 6 +- .../api/app/bsky/graph/getList.ts | 4 +- .../api/app/bsky/graph/getListBlocks.ts | 4 +- .../api/app/bsky/graph/getListMutes.ts | 4 +- .../api/app/bsky/graph/getLists.ts | 4 +- .../api/app/bsky/graph/getMutes.ts | 4 +- .../bsky/graph/getSuggestedFollowsByActor.ts | 4 +- packages/pds/src/api/app/bsky/graph/index.ts | 31 ++++++++ .../api/app/bsky/graph/muteActor.ts | 4 +- .../api/app/bsky/graph/muteActorList.ts | 6 +- .../api/app/bsky/graph/unmuteActor.ts | 4 +- .../api/app/bsky/graph/unmuteActorList.ts | 4 +- packages/pds/src/api/app/bsky/index.ts | 8 ++ .../app/bsky/notification/getUnreadCount.ts | 4 +- .../src/api/app/bsky/notification/index.ts | 14 ++++ .../bsky/notification/listNotifications.ts | 4 +- .../api/app/bsky/notification/registerPush.ts | 4 +- .../api/app/bsky/notification/updateSeen.ts | 4 +- .../src/api/app/bsky/unspecced/getPopular.ts | 23 ++++++ .../unspecced/getPopularFeedGenerators.ts | 21 +++++ .../pds/src/api/app/bsky/unspecced/index.ts | 10 +++ .../api/app/bsky/util/read-after-write.ts | 6 +- .../api/app/bsky/util/resolver.ts | 2 +- .../pds/src/app-view/api/app/bsky/index.ts | 77 ------------------- .../src/app-view/api/app/bsky/unspecced.ts | 68 ---------------- packages/pds/src/app-view/api/index.ts | 8 -- packages/pds/src/app-view/logger.ts | 3 - packages/pds/src/index.ts | 2 - 50 files changed, 243 insertions(+), 253 deletions(-) rename packages/pds/src/{app-view => }/api/app/bsky/actor/getProfile.ts (76%) rename packages/pds/src/{app-view => }/api/app/bsky/actor/getProfiles.ts (82%) rename packages/pds/src/{app-view => }/api/app/bsky/actor/getSuggestions.ts (82%) rename packages/pds/src/{app-view => }/api/app/bsky/actor/searchActors.ts (82%) rename packages/pds/src/{app-view => }/api/app/bsky/actor/searchActorsTypeahead.ts (83%) rename packages/pds/src/{app-view => }/api/app/bsky/feed/getActorFeeds.ts (82%) rename packages/pds/src/{app-view => }/api/app/bsky/feed/getActorLikes.ts (82%) rename packages/pds/src/{app-view => }/api/app/bsky/feed/getAuthorFeed.ts (83%) rename packages/pds/src/{app-view => }/api/app/bsky/feed/getFeed.ts (87%) rename packages/pds/src/{app-view => }/api/app/bsky/feed/getFeedGenerator.ts (83%) rename packages/pds/src/{app-view => }/api/app/bsky/feed/getFeedGenerators.ts (83%) rename packages/pds/src/{app-view => }/api/app/bsky/feed/getLikes.ts (82%) rename packages/pds/src/{app-view => }/api/app/bsky/feed/getListFeed.ts (82%) rename packages/pds/src/{app-view => }/api/app/bsky/feed/getPostThread.ts (94%) rename packages/pds/src/{app-view => }/api/app/bsky/feed/getPosts.ts (82%) rename packages/pds/src/{app-view => }/api/app/bsky/feed/getRepostedBy.ts (82%) rename packages/pds/src/{app-view => }/api/app/bsky/feed/getSuggestedFeeds.ts (83%) rename packages/pds/src/{app-view => }/api/app/bsky/feed/getTimeline.ts (76%) create mode 100644 packages/pds/src/api/app/bsky/feed/index.ts rename packages/pds/src/{app-view => }/api/app/bsky/graph/getBlocks.ts (82%) rename packages/pds/src/{app-view => }/api/app/bsky/graph/getFollowers.ts (76%) rename packages/pds/src/{app-view => }/api/app/bsky/graph/getFollows.ts (76%) rename packages/pds/src/{app-view => }/api/app/bsky/graph/getList.ts (82%) rename packages/pds/src/{app-view => }/api/app/bsky/graph/getListBlocks.ts (82%) rename packages/pds/src/{app-view => }/api/app/bsky/graph/getListMutes.ts (82%) rename packages/pds/src/{app-view => }/api/app/bsky/graph/getLists.ts (82%) rename packages/pds/src/{app-view => }/api/app/bsky/graph/getMutes.ts (82%) rename packages/pds/src/{app-view => }/api/app/bsky/graph/getSuggestedFollowsByActor.ts (84%) create mode 100644 packages/pds/src/api/app/bsky/graph/index.ts rename packages/pds/src/{app-view => }/api/app/bsky/graph/muteActor.ts (90%) rename packages/pds/src/{app-view => }/api/app/bsky/graph/muteActorList.ts (85%) rename packages/pds/src/{app-view => }/api/app/bsky/graph/unmuteActor.ts (89%) rename packages/pds/src/{app-view => }/api/app/bsky/graph/unmuteActorList.ts (86%) rename packages/pds/src/{app-view => }/api/app/bsky/notification/getUnreadCount.ts (83%) create mode 100644 packages/pds/src/api/app/bsky/notification/index.ts rename packages/pds/src/{app-view => }/api/app/bsky/notification/listNotifications.ts (83%) rename packages/pds/src/{app-view => }/api/app/bsky/notification/registerPush.ts (93%) rename packages/pds/src/{app-view => }/api/app/bsky/notification/updateSeen.ts (92%) create mode 100644 packages/pds/src/api/app/bsky/unspecced/getPopular.ts create mode 100644 packages/pds/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts create mode 100644 packages/pds/src/api/app/bsky/unspecced/index.ts rename packages/pds/src/{app-view => }/api/app/bsky/util/read-after-write.ts (91%) rename packages/pds/src/{app-view => }/api/app/bsky/util/resolver.ts (93%) delete mode 100644 packages/pds/src/app-view/api/app/bsky/index.ts delete mode 100644 packages/pds/src/app-view/api/app/bsky/unspecced.ts delete mode 100644 packages/pds/src/app-view/api/index.ts delete mode 100644 packages/pds/src/app-view/logger.ts diff --git a/packages/pds/src/app-view/api/app/bsky/actor/getProfile.ts b/packages/pds/src/api/app/bsky/actor/getProfile.ts similarity index 76% rename from packages/pds/src/app-view/api/app/bsky/actor/getProfile.ts rename to packages/pds/src/api/app/bsky/actor/getProfile.ts index 4d510bda720..52858515827 100644 --- a/packages/pds/src/app-view/api/app/bsky/actor/getProfile.ts +++ b/packages/pds/src/api/app/bsky/actor/getProfile.ts @@ -1,9 +1,9 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' -import { authPassthru } from '../../../../../api/com/atproto/admin/util' -import { OutputSchema } from '../../../../../lexicon/types/app/bsky/actor/getProfile' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' +import { authPassthru } from '../../../../api/com/atproto/admin/util' +import { OutputSchema } from '../../../../lexicon/types/app/bsky/actor/getProfile' import { handleReadAfterWrite } from '../util/read-after-write' -import { LocalRecords } from '../../../../../services/local' +import { LocalRecords } from '../../../../services/local' export default function (server: Server, ctx: AppContext) { server.app.bsky.actor.getProfile({ diff --git a/packages/pds/src/app-view/api/app/bsky/actor/getProfiles.ts b/packages/pds/src/api/app/bsky/actor/getProfiles.ts similarity index 82% rename from packages/pds/src/app-view/api/app/bsky/actor/getProfiles.ts rename to packages/pds/src/api/app/bsky/actor/getProfiles.ts index 08f30dfe690..46af4b08a0c 100644 --- a/packages/pds/src/app-view/api/app/bsky/actor/getProfiles.ts +++ b/packages/pds/src/api/app/bsky/actor/getProfiles.ts @@ -1,7 +1,7 @@ -import AppContext from '../../../../../context' -import { Server } from '../../../../../lexicon' -import { OutputSchema } from '../../../../../lexicon/types/app/bsky/actor/getProfiles' -import { LocalRecords } from '../../../../../services/local' +import AppContext from '../../../../context' +import { Server } from '../../../../lexicon' +import { OutputSchema } from '../../../../lexicon/types/app/bsky/actor/getProfiles' +import { LocalRecords } from '../../../../services/local' import { handleReadAfterWrite } from '../util/read-after-write' export default function (server: Server, ctx: AppContext) { diff --git a/packages/pds/src/app-view/api/app/bsky/actor/getSuggestions.ts b/packages/pds/src/api/app/bsky/actor/getSuggestions.ts similarity index 82% rename from packages/pds/src/app-view/api/app/bsky/actor/getSuggestions.ts rename to packages/pds/src/api/app/bsky/actor/getSuggestions.ts index 9047634dd30..c3ceb16cf14 100644 --- a/packages/pds/src/app-view/api/app/bsky/actor/getSuggestions.ts +++ b/packages/pds/src/api/app/bsky/actor/getSuggestions.ts @@ -1,5 +1,5 @@ -import AppContext from '../../../../../context' -import { Server } from '../../../../../lexicon' +import AppContext from '../../../../context' +import { Server } from '../../../../lexicon' export default function (server: Server, ctx: AppContext) { server.app.bsky.actor.getSuggestions({ diff --git a/packages/pds/src/api/app/bsky/actor/index.ts b/packages/pds/src/api/app/bsky/actor/index.ts index a2561170571..db69616f7e8 100644 --- a/packages/pds/src/api/app/bsky/actor/index.ts +++ b/packages/pds/src/api/app/bsky/actor/index.ts @@ -1,9 +1,19 @@ import { Server } from '../../../../lexicon' import AppContext from '../../../../context' import getPreferences from './getPreferences' +import getProfile from './getProfile' +import getProfiles from './getProfiles' +import getSuggestions from './getSuggestions' import putPreferences from './putPreferences' +import searchActors from './searchActors' +import searchActorsTypeahead from './searchActorsTypeahead' export default function (server: Server, ctx: AppContext) { getPreferences(server, ctx) + getProfile(server, ctx) + getProfiles(server, ctx) + getSuggestions(server, ctx) putPreferences(server, ctx) + searchActors(server, ctx) + searchActorsTypeahead(server, ctx) } diff --git a/packages/pds/src/app-view/api/app/bsky/actor/searchActors.ts b/packages/pds/src/api/app/bsky/actor/searchActors.ts similarity index 82% rename from packages/pds/src/app-view/api/app/bsky/actor/searchActors.ts rename to packages/pds/src/api/app/bsky/actor/searchActors.ts index ff88cd8d233..921f4363bfc 100644 --- a/packages/pds/src/app-view/api/app/bsky/actor/searchActors.ts +++ b/packages/pds/src/api/app/bsky/actor/searchActors.ts @@ -1,5 +1,5 @@ -import AppContext from '../../../../../context' -import { Server } from '../../../../../lexicon' +import AppContext from '../../../../context' +import { Server } from '../../../../lexicon' export default function (server: Server, ctx: AppContext) { server.app.bsky.actor.searchActors({ diff --git a/packages/pds/src/app-view/api/app/bsky/actor/searchActorsTypeahead.ts b/packages/pds/src/api/app/bsky/actor/searchActorsTypeahead.ts similarity index 83% rename from packages/pds/src/app-view/api/app/bsky/actor/searchActorsTypeahead.ts rename to packages/pds/src/api/app/bsky/actor/searchActorsTypeahead.ts index 5853cf3104e..d8ef8f72dda 100644 --- a/packages/pds/src/app-view/api/app/bsky/actor/searchActorsTypeahead.ts +++ b/packages/pds/src/api/app/bsky/actor/searchActorsTypeahead.ts @@ -1,5 +1,5 @@ -import AppContext from '../../../../../context' -import { Server } from '../../../../../lexicon' +import AppContext from '../../../../context' +import { Server } from '../../../../lexicon' export default function (server: Server, ctx: AppContext) { server.app.bsky.actor.searchActorsTypeahead({ diff --git a/packages/pds/src/app-view/api/app/bsky/feed/getActorFeeds.ts b/packages/pds/src/api/app/bsky/feed/getActorFeeds.ts similarity index 82% rename from packages/pds/src/app-view/api/app/bsky/feed/getActorFeeds.ts rename to packages/pds/src/api/app/bsky/feed/getActorFeeds.ts index 57d7d72b6e4..ec77754b4b2 100644 --- a/packages/pds/src/app-view/api/app/bsky/feed/getActorFeeds.ts +++ b/packages/pds/src/api/app/bsky/feed/getActorFeeds.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getActorFeeds({ diff --git a/packages/pds/src/app-view/api/app/bsky/feed/getActorLikes.ts b/packages/pds/src/api/app/bsky/feed/getActorLikes.ts similarity index 82% rename from packages/pds/src/app-view/api/app/bsky/feed/getActorLikes.ts rename to packages/pds/src/api/app/bsky/feed/getActorLikes.ts index 6e56bc81214..53557c6ae4c 100644 --- a/packages/pds/src/app-view/api/app/bsky/feed/getActorLikes.ts +++ b/packages/pds/src/api/app/bsky/feed/getActorLikes.ts @@ -1,9 +1,9 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' -import { OutputSchema } from '../../../../../lexicon/types/app/bsky/feed/getAuthorFeed' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' +import { OutputSchema } from '../../../../lexicon/types/app/bsky/feed/getAuthorFeed' import { handleReadAfterWrite } from '../util/read-after-write' -import { authPassthru } from '../../../../../api/com/atproto/admin/util' -import { LocalRecords } from '../../../../../services/local' +import { authPassthru } from '../../../../api/com/atproto/admin/util' +import { LocalRecords } from '../../../../services/local' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getActorLikes({ diff --git a/packages/pds/src/app-view/api/app/bsky/feed/getAuthorFeed.ts b/packages/pds/src/api/app/bsky/feed/getAuthorFeed.ts similarity index 83% rename from packages/pds/src/app-view/api/app/bsky/feed/getAuthorFeed.ts rename to packages/pds/src/api/app/bsky/feed/getAuthorFeed.ts index 735004f52e3..7237a2df755 100644 --- a/packages/pds/src/app-view/api/app/bsky/feed/getAuthorFeed.ts +++ b/packages/pds/src/api/app/bsky/feed/getAuthorFeed.ts @@ -1,10 +1,10 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' -import { OutputSchema } from '../../../../../lexicon/types/app/bsky/feed/getAuthorFeed' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' +import { OutputSchema } from '../../../../lexicon/types/app/bsky/feed/getAuthorFeed' import { handleReadAfterWrite } from '../util/read-after-write' -import { authPassthru } from '../../../../../api/com/atproto/admin/util' -import { LocalRecords } from '../../../../../services/local' -import { isReasonRepost } from '../../../../../lexicon/types/app/bsky/feed/defs' +import { authPassthru } from '../../../../api/com/atproto/admin/util' +import { LocalRecords } from '../../../../services/local' +import { isReasonRepost } from '../../../../lexicon/types/app/bsky/feed/defs' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getAuthorFeed({ diff --git a/packages/pds/src/app-view/api/app/bsky/feed/getFeed.ts b/packages/pds/src/api/app/bsky/feed/getFeed.ts similarity index 87% rename from packages/pds/src/app-view/api/app/bsky/feed/getFeed.ts rename to packages/pds/src/api/app/bsky/feed/getFeed.ts index a5cf4176d4e..6ed14b0546c 100644 --- a/packages/pds/src/app-view/api/app/bsky/feed/getFeed.ts +++ b/packages/pds/src/api/app/bsky/feed/getFeed.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getFeed({ diff --git a/packages/pds/src/app-view/api/app/bsky/feed/getFeedGenerator.ts b/packages/pds/src/api/app/bsky/feed/getFeedGenerator.ts similarity index 83% rename from packages/pds/src/app-view/api/app/bsky/feed/getFeedGenerator.ts rename to packages/pds/src/api/app/bsky/feed/getFeedGenerator.ts index 210b1be54ef..b9451ca16c3 100644 --- a/packages/pds/src/app-view/api/app/bsky/feed/getFeedGenerator.ts +++ b/packages/pds/src/api/app/bsky/feed/getFeedGenerator.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getFeedGenerator({ diff --git a/packages/pds/src/app-view/api/app/bsky/feed/getFeedGenerators.ts b/packages/pds/src/api/app/bsky/feed/getFeedGenerators.ts similarity index 83% rename from packages/pds/src/app-view/api/app/bsky/feed/getFeedGenerators.ts rename to packages/pds/src/api/app/bsky/feed/getFeedGenerators.ts index 36353f015b7..1d085830004 100644 --- a/packages/pds/src/app-view/api/app/bsky/feed/getFeedGenerators.ts +++ b/packages/pds/src/api/app/bsky/feed/getFeedGenerators.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getFeedGenerators({ diff --git a/packages/pds/src/app-view/api/app/bsky/feed/getLikes.ts b/packages/pds/src/api/app/bsky/feed/getLikes.ts similarity index 82% rename from packages/pds/src/app-view/api/app/bsky/feed/getLikes.ts rename to packages/pds/src/api/app/bsky/feed/getLikes.ts index a78469355d5..75197acbcc8 100644 --- a/packages/pds/src/app-view/api/app/bsky/feed/getLikes.ts +++ b/packages/pds/src/api/app/bsky/feed/getLikes.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getLikes({ diff --git a/packages/pds/src/app-view/api/app/bsky/feed/getListFeed.ts b/packages/pds/src/api/app/bsky/feed/getListFeed.ts similarity index 82% rename from packages/pds/src/app-view/api/app/bsky/feed/getListFeed.ts rename to packages/pds/src/api/app/bsky/feed/getListFeed.ts index 1ac1e983861..7344b2476ba 100644 --- a/packages/pds/src/app-view/api/app/bsky/feed/getListFeed.ts +++ b/packages/pds/src/api/app/bsky/feed/getListFeed.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getListFeed({ diff --git a/packages/pds/src/app-view/api/app/bsky/feed/getPostThread.ts b/packages/pds/src/api/app/bsky/feed/getPostThread.ts similarity index 94% rename from packages/pds/src/app-view/api/app/bsky/feed/getPostThread.ts rename to packages/pds/src/api/app/bsky/feed/getPostThread.ts index be1e8004bac..e8dd062da14 100644 --- a/packages/pds/src/app-view/api/app/bsky/feed/getPostThread.ts +++ b/packages/pds/src/api/app/bsky/feed/getPostThread.ts @@ -1,22 +1,22 @@ import { AtUri } from '@atproto/syntax' import { AppBskyFeedGetPostThread } from '@atproto/api' import { Headers } from '@atproto/xrpc' -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' import { ThreadViewPost, isThreadViewPost, -} from '../../../../../lexicon/types/app/bsky/feed/defs' -import { Record as PostRecord } from '../../../../../lexicon/types/app/bsky/feed/post' +} from '../../../../lexicon/types/app/bsky/feed/defs' +import { Record as PostRecord } from '../../../../lexicon/types/app/bsky/feed/post' import { OutputSchema, QueryParams, -} from '../../../../../lexicon/types/app/bsky/feed/getPostThread' +} from '../../../../lexicon/types/app/bsky/feed/getPostThread' import { LocalRecords, LocalService, RecordDescript, -} from '../../../../../services/local' +} from '../../../../services/local' import { getLocalLag, getRepoRev, diff --git a/packages/pds/src/app-view/api/app/bsky/feed/getPosts.ts b/packages/pds/src/api/app/bsky/feed/getPosts.ts similarity index 82% rename from packages/pds/src/app-view/api/app/bsky/feed/getPosts.ts rename to packages/pds/src/api/app/bsky/feed/getPosts.ts index f394ae57a08..05173c48ef9 100644 --- a/packages/pds/src/app-view/api/app/bsky/feed/getPosts.ts +++ b/packages/pds/src/api/app/bsky/feed/getPosts.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getPosts({ diff --git a/packages/pds/src/app-view/api/app/bsky/feed/getRepostedBy.ts b/packages/pds/src/api/app/bsky/feed/getRepostedBy.ts similarity index 82% rename from packages/pds/src/app-view/api/app/bsky/feed/getRepostedBy.ts rename to packages/pds/src/api/app/bsky/feed/getRepostedBy.ts index 9704597ad27..44a5b15191d 100644 --- a/packages/pds/src/app-view/api/app/bsky/feed/getRepostedBy.ts +++ b/packages/pds/src/api/app/bsky/feed/getRepostedBy.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getRepostedBy({ diff --git a/packages/pds/src/app-view/api/app/bsky/feed/getSuggestedFeeds.ts b/packages/pds/src/api/app/bsky/feed/getSuggestedFeeds.ts similarity index 83% rename from packages/pds/src/app-view/api/app/bsky/feed/getSuggestedFeeds.ts rename to packages/pds/src/api/app/bsky/feed/getSuggestedFeeds.ts index 37f06390fb9..9c8d338104b 100644 --- a/packages/pds/src/app-view/api/app/bsky/feed/getSuggestedFeeds.ts +++ b/packages/pds/src/api/app/bsky/feed/getSuggestedFeeds.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getSuggestedFeeds({ diff --git a/packages/pds/src/app-view/api/app/bsky/feed/getTimeline.ts b/packages/pds/src/api/app/bsky/feed/getTimeline.ts similarity index 76% rename from packages/pds/src/app-view/api/app/bsky/feed/getTimeline.ts rename to packages/pds/src/api/app/bsky/feed/getTimeline.ts index 08676b3a943..7d4e52ce918 100644 --- a/packages/pds/src/app-view/api/app/bsky/feed/getTimeline.ts +++ b/packages/pds/src/api/app/bsky/feed/getTimeline.ts @@ -1,8 +1,8 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' -import { OutputSchema } from '../../../../../lexicon/types/app/bsky/feed/getTimeline' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' +import { OutputSchema } from '../../../../lexicon/types/app/bsky/feed/getTimeline' import { handleReadAfterWrite } from '../util/read-after-write' -import { LocalRecords } from '../../../../../services/local' +import { LocalRecords } from '../../../../services/local' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getTimeline({ diff --git a/packages/pds/src/api/app/bsky/feed/index.ts b/packages/pds/src/api/app/bsky/feed/index.ts new file mode 100644 index 00000000000..8c4cfaa8b5f --- /dev/null +++ b/packages/pds/src/api/app/bsky/feed/index.ts @@ -0,0 +1,31 @@ +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' +import getActorFeeds from './getActorFeeds' +import getActorLikes from './getActorLikes' +import getAuthorFeed from './getAuthorFeed' +import getFeed from './getFeed' +import getFeedGenerator from './getFeedGenerator' +import getFeedGenerators from './getFeedGenerators' +import getLikes from './getLikes' +import getListFeed from './getListFeed' +import getPosts from './getPosts' +import getPostThread from './getPostThread' +import getRepostedBy from './getRepostedBy' +import getSuggestedFeeds from './getSuggestedFeeds' +import getTimeline from './getTimeline' + +export default function (server: Server, ctx: AppContext) { + getActorFeeds(server, ctx) + getActorLikes(server, ctx) + getAuthorFeed(server, ctx) + getFeed(server, ctx) + getFeedGenerator(server, ctx) + getFeedGenerators(server, ctx) + getLikes(server, ctx) + getListFeed(server, ctx) + getPosts(server, ctx) + getPostThread(server, ctx) + getRepostedBy(server, ctx) + getSuggestedFeeds(server, ctx) + getTimeline(server, ctx) +} diff --git a/packages/pds/src/app-view/api/app/bsky/graph/getBlocks.ts b/packages/pds/src/api/app/bsky/graph/getBlocks.ts similarity index 82% rename from packages/pds/src/app-view/api/app/bsky/graph/getBlocks.ts rename to packages/pds/src/api/app/bsky/graph/getBlocks.ts index 52f7b4d6f7f..284dafd3034 100644 --- a/packages/pds/src/app-view/api/app/bsky/graph/getBlocks.ts +++ b/packages/pds/src/api/app/bsky/graph/getBlocks.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.graph.getBlocks({ diff --git a/packages/pds/src/app-view/api/app/bsky/graph/getFollowers.ts b/packages/pds/src/api/app/bsky/graph/getFollowers.ts similarity index 76% rename from packages/pds/src/app-view/api/app/bsky/graph/getFollowers.ts rename to packages/pds/src/api/app/bsky/graph/getFollowers.ts index 0c7f23869eb..da0541d7e75 100644 --- a/packages/pds/src/app-view/api/app/bsky/graph/getFollowers.ts +++ b/packages/pds/src/api/app/bsky/graph/getFollowers.ts @@ -1,6 +1,6 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' -import { authPassthru } from '../../../../../api/com/atproto/admin/util' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' +import { authPassthru } from '../../../../api/com/atproto/admin/util' export default function (server: Server, ctx: AppContext) { server.app.bsky.graph.getFollowers({ diff --git a/packages/pds/src/app-view/api/app/bsky/graph/getFollows.ts b/packages/pds/src/api/app/bsky/graph/getFollows.ts similarity index 76% rename from packages/pds/src/app-view/api/app/bsky/graph/getFollows.ts rename to packages/pds/src/api/app/bsky/graph/getFollows.ts index 5871a213302..f49c812f9ca 100644 --- a/packages/pds/src/app-view/api/app/bsky/graph/getFollows.ts +++ b/packages/pds/src/api/app/bsky/graph/getFollows.ts @@ -1,6 +1,6 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' -import { authPassthru } from '../../../../../api/com/atproto/admin/util' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' +import { authPassthru } from '../../../../api/com/atproto/admin/util' export default function (server: Server, ctx: AppContext) { server.app.bsky.graph.getFollows({ diff --git a/packages/pds/src/app-view/api/app/bsky/graph/getList.ts b/packages/pds/src/api/app/bsky/graph/getList.ts similarity index 82% rename from packages/pds/src/app-view/api/app/bsky/graph/getList.ts rename to packages/pds/src/api/app/bsky/graph/getList.ts index ba9b9f9346f..5fd3c93df75 100644 --- a/packages/pds/src/app-view/api/app/bsky/graph/getList.ts +++ b/packages/pds/src/api/app/bsky/graph/getList.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.graph.getList({ diff --git a/packages/pds/src/app-view/api/app/bsky/graph/getListBlocks.ts b/packages/pds/src/api/app/bsky/graph/getListBlocks.ts similarity index 82% rename from packages/pds/src/app-view/api/app/bsky/graph/getListBlocks.ts rename to packages/pds/src/api/app/bsky/graph/getListBlocks.ts index 98c55e14bc9..04fd55a324e 100644 --- a/packages/pds/src/app-view/api/app/bsky/graph/getListBlocks.ts +++ b/packages/pds/src/api/app/bsky/graph/getListBlocks.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.graph.getListBlocks({ diff --git a/packages/pds/src/app-view/api/app/bsky/graph/getListMutes.ts b/packages/pds/src/api/app/bsky/graph/getListMutes.ts similarity index 82% rename from packages/pds/src/app-view/api/app/bsky/graph/getListMutes.ts rename to packages/pds/src/api/app/bsky/graph/getListMutes.ts index adae96d58b0..e0a624a3864 100644 --- a/packages/pds/src/app-view/api/app/bsky/graph/getListMutes.ts +++ b/packages/pds/src/api/app/bsky/graph/getListMutes.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.graph.getListMutes({ diff --git a/packages/pds/src/app-view/api/app/bsky/graph/getLists.ts b/packages/pds/src/api/app/bsky/graph/getLists.ts similarity index 82% rename from packages/pds/src/app-view/api/app/bsky/graph/getLists.ts rename to packages/pds/src/api/app/bsky/graph/getLists.ts index 893b6d5a9ad..e43a8d2b1d6 100644 --- a/packages/pds/src/app-view/api/app/bsky/graph/getLists.ts +++ b/packages/pds/src/api/app/bsky/graph/getLists.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.graph.getLists({ diff --git a/packages/pds/src/app-view/api/app/bsky/graph/getMutes.ts b/packages/pds/src/api/app/bsky/graph/getMutes.ts similarity index 82% rename from packages/pds/src/app-view/api/app/bsky/graph/getMutes.ts rename to packages/pds/src/api/app/bsky/graph/getMutes.ts index 596fef9dd15..9aa6b74445c 100644 --- a/packages/pds/src/app-view/api/app/bsky/graph/getMutes.ts +++ b/packages/pds/src/api/app/bsky/graph/getMutes.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.graph.getMutes({ diff --git a/packages/pds/src/app-view/api/app/bsky/graph/getSuggestedFollowsByActor.ts b/packages/pds/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts similarity index 84% rename from packages/pds/src/app-view/api/app/bsky/graph/getSuggestedFollowsByActor.ts rename to packages/pds/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts index dfafa6b65ea..1db1c7f498f 100644 --- a/packages/pds/src/app-view/api/app/bsky/graph/getSuggestedFollowsByActor.ts +++ b/packages/pds/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.graph.getSuggestedFollowsByActor({ diff --git a/packages/pds/src/api/app/bsky/graph/index.ts b/packages/pds/src/api/app/bsky/graph/index.ts new file mode 100644 index 00000000000..0c18b9e51b4 --- /dev/null +++ b/packages/pds/src/api/app/bsky/graph/index.ts @@ -0,0 +1,31 @@ +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' +import getBlocks from './getBlocks' +import getFollowers from './getFollowers' +import getFollows from './getFollows' +import getList from './getList' +import getListBlocks from './getListBlocks' +import getListMutes from './getListMutes' +import getLists from './getLists' +import getMutes from './getMutes' +import getSuggestedFollowsByActor from './getSuggestedFollowsByActor' +import muteActor from './muteActor' +import muteActorList from './muteActorList' +import unmuteActor from './unmuteActor' +import unmuteActorList from './unmuteActorList' + +export default function (server: Server, ctx: AppContext) { + getBlocks(server, ctx) + getFollowers(server, ctx) + getFollows(server, ctx) + getList(server, ctx) + getListBlocks(server, ctx) + getListMutes(server, ctx) + getLists(server, ctx) + getMutes(server, ctx) + getSuggestedFollowsByActor(server, ctx) + muteActor(server, ctx) + muteActorList(server, ctx) + unmuteActor(server, ctx) + unmuteActorList(server, ctx) +} diff --git a/packages/pds/src/app-view/api/app/bsky/graph/muteActor.ts b/packages/pds/src/api/app/bsky/graph/muteActor.ts similarity index 90% rename from packages/pds/src/app-view/api/app/bsky/graph/muteActor.ts rename to packages/pds/src/api/app/bsky/graph/muteActor.ts index 4cae0c45e27..44d4747f5e9 100644 --- a/packages/pds/src/app-view/api/app/bsky/graph/muteActor.ts +++ b/packages/pds/src/api/app/bsky/graph/muteActor.ts @@ -1,6 +1,6 @@ import { InvalidRequestError } from '@atproto/xrpc-server' -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.graph.muteActor({ diff --git a/packages/pds/src/app-view/api/app/bsky/graph/muteActorList.ts b/packages/pds/src/api/app/bsky/graph/muteActorList.ts similarity index 85% rename from packages/pds/src/app-view/api/app/bsky/graph/muteActorList.ts rename to packages/pds/src/api/app/bsky/graph/muteActorList.ts index 728aa2a5837..e554f7fce8b 100644 --- a/packages/pds/src/app-view/api/app/bsky/graph/muteActorList.ts +++ b/packages/pds/src/api/app/bsky/graph/muteActorList.ts @@ -1,6 +1,6 @@ -import { Server } from '../../../../../lexicon' -import * as lex from '../../../../../lexicon/lexicons' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import * as lex from '../../../../lexicon/lexicons' +import AppContext from '../../../../context' import { AtUri } from '@atproto/syntax' import { InvalidRequestError } from '@atproto/xrpc-server' diff --git a/packages/pds/src/app-view/api/app/bsky/graph/unmuteActor.ts b/packages/pds/src/api/app/bsky/graph/unmuteActor.ts similarity index 89% rename from packages/pds/src/app-view/api/app/bsky/graph/unmuteActor.ts rename to packages/pds/src/api/app/bsky/graph/unmuteActor.ts index ed9585a60b5..84819cc1e15 100644 --- a/packages/pds/src/app-view/api/app/bsky/graph/unmuteActor.ts +++ b/packages/pds/src/api/app/bsky/graph/unmuteActor.ts @@ -1,6 +1,6 @@ -import { Server } from '../../../../../lexicon' +import { Server } from '../../../../lexicon' import { InvalidRequestError } from '@atproto/xrpc-server' -import AppContext from '../../../../../context' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.graph.unmuteActor({ diff --git a/packages/pds/src/app-view/api/app/bsky/graph/unmuteActorList.ts b/packages/pds/src/api/app/bsky/graph/unmuteActorList.ts similarity index 86% rename from packages/pds/src/app-view/api/app/bsky/graph/unmuteActorList.ts rename to packages/pds/src/api/app/bsky/graph/unmuteActorList.ts index 6141bd619bc..ce3c1a4b254 100644 --- a/packages/pds/src/app-view/api/app/bsky/graph/unmuteActorList.ts +++ b/packages/pds/src/api/app/bsky/graph/unmuteActorList.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.graph.unmuteActorList({ diff --git a/packages/pds/src/api/app/bsky/index.ts b/packages/pds/src/api/app/bsky/index.ts index ad7675caeb6..8f38a52683f 100644 --- a/packages/pds/src/api/app/bsky/index.ts +++ b/packages/pds/src/api/app/bsky/index.ts @@ -1,7 +1,15 @@ import { Server } from '../../../lexicon' import AppContext from '../../../context' import actor from './actor' +import feed from './feed' +import graph from './graph' +import notification from './notification' +import unspecced from './unspecced' export default function (server: Server, ctx: AppContext) { actor(server, ctx) + feed(server, ctx) + graph(server, ctx) + notification(server, ctx) + unspecced(server, ctx) } diff --git a/packages/pds/src/app-view/api/app/bsky/notification/getUnreadCount.ts b/packages/pds/src/api/app/bsky/notification/getUnreadCount.ts similarity index 83% rename from packages/pds/src/app-view/api/app/bsky/notification/getUnreadCount.ts rename to packages/pds/src/api/app/bsky/notification/getUnreadCount.ts index 61c2b48f1e3..e8100b183c5 100644 --- a/packages/pds/src/app-view/api/app/bsky/notification/getUnreadCount.ts +++ b/packages/pds/src/api/app/bsky/notification/getUnreadCount.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.notification.getUnreadCount({ diff --git a/packages/pds/src/api/app/bsky/notification/index.ts b/packages/pds/src/api/app/bsky/notification/index.ts new file mode 100644 index 00000000000..f5d8ee59449 --- /dev/null +++ b/packages/pds/src/api/app/bsky/notification/index.ts @@ -0,0 +1,14 @@ +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' + +import getUnreadCount from './getUnreadCount' +import listNotifications from './listNotifications' +import registerPush from './registerPush' +import updateSeen from './updateSeen' + +export default function (server: Server, ctx: AppContext) { + getUnreadCount(server, ctx) + listNotifications(server, ctx) + registerPush(server, ctx) + updateSeen(server, ctx) +} diff --git a/packages/pds/src/app-view/api/app/bsky/notification/listNotifications.ts b/packages/pds/src/api/app/bsky/notification/listNotifications.ts similarity index 83% rename from packages/pds/src/app-view/api/app/bsky/notification/listNotifications.ts rename to packages/pds/src/api/app/bsky/notification/listNotifications.ts index eefb3d29a48..2f667172a57 100644 --- a/packages/pds/src/app-view/api/app/bsky/notification/listNotifications.ts +++ b/packages/pds/src/api/app/bsky/notification/listNotifications.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.notification.listNotifications({ diff --git a/packages/pds/src/app-view/api/app/bsky/notification/registerPush.ts b/packages/pds/src/api/app/bsky/notification/registerPush.ts similarity index 93% rename from packages/pds/src/app-view/api/app/bsky/notification/registerPush.ts rename to packages/pds/src/api/app/bsky/notification/registerPush.ts index bb2d329e8e7..1abe5b83ed7 100644 --- a/packages/pds/src/app-view/api/app/bsky/notification/registerPush.ts +++ b/packages/pds/src/api/app/bsky/notification/registerPush.ts @@ -1,5 +1,5 @@ -import { Server } from '../../../../../lexicon' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' import { getNotif } from '@atproto/identity' import { InvalidRequestError } from '@atproto/xrpc-server' import { AtpAgent } from '@atproto/api' diff --git a/packages/pds/src/app-view/api/app/bsky/notification/updateSeen.ts b/packages/pds/src/api/app/bsky/notification/updateSeen.ts similarity index 92% rename from packages/pds/src/app-view/api/app/bsky/notification/updateSeen.ts rename to packages/pds/src/api/app/bsky/notification/updateSeen.ts index 0524a1e8581..2c115a61f67 100644 --- a/packages/pds/src/app-view/api/app/bsky/notification/updateSeen.ts +++ b/packages/pds/src/api/app/bsky/notification/updateSeen.ts @@ -1,6 +1,6 @@ -import { Server } from '../../../../../lexicon' import { InvalidRequestError } from '@atproto/xrpc-server' -import AppContext from '../../../../../context' +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.notification.updateSeen({ diff --git a/packages/pds/src/api/app/bsky/unspecced/getPopular.ts b/packages/pds/src/api/app/bsky/unspecced/getPopular.ts new file mode 100644 index 00000000000..c4b4736cdc0 --- /dev/null +++ b/packages/pds/src/api/app/bsky/unspecced/getPopular.ts @@ -0,0 +1,23 @@ +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' + +// THIS IS A TEMPORARY UNSPECCED ROUTE +export default function (server: Server, ctx: AppContext) { + server.app.bsky.unspecced.getPopular({ + auth: ctx.accessVerifier, + handler: async ({ auth, params }) => { + const requester = auth.credentials.did + const HOT_CLASSIC_URI = + 'at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/hot-classic' + const HOT_CLASSIC_DID = 'did:plc:5fllqkujj6kqp5izd5jg7gox' + const res = await ctx.appviewAgent.api.app.bsky.feed.getFeed( + { feed: HOT_CLASSIC_URI, limit: params.limit, cursor: params.cursor }, + await ctx.serviceAuthHeaders(requester, HOT_CLASSIC_DID), + ) + 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 new file mode 100644 index 00000000000..3f41f18560c --- /dev/null +++ b/packages/pds/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts @@ -0,0 +1,21 @@ +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' + +// THIS IS A TEMPORARY UNSPECCED ROUTE +export default function (server: Server, ctx: AppContext) { + server.app.bsky.unspecced.getPopularFeedGenerators({ + auth: ctx.accessVerifier, + handler: async ({ auth, params }) => { + const requester = auth.credentials.did + const res = + await ctx.appviewAgent.api.app.bsky.unspecced.getPopularFeedGenerators( + params, + await ctx.serviceAuthHeaders(requester), + ) + return { + encoding: 'application/json', + body: res.data, + } + }, + }) +} diff --git a/packages/pds/src/api/app/bsky/unspecced/index.ts b/packages/pds/src/api/app/bsky/unspecced/index.ts new file mode 100644 index 00000000000..6951400863d --- /dev/null +++ b/packages/pds/src/api/app/bsky/unspecced/index.ts @@ -0,0 +1,10 @@ +import { Server } from '../../../../lexicon' +import AppContext from '../../../../context' +import getPopular from './getPopular' +import getPopularFeedGenerators from './getPopularFeedGenerators' + +// THIS IS A TEMPORARY UNSPECCED ROUTE +export default function (server: Server, ctx: AppContext) { + getPopular(server, ctx) + getPopularFeedGenerators(server, ctx) +} diff --git a/packages/pds/src/app-view/api/app/bsky/util/read-after-write.ts b/packages/pds/src/api/app/bsky/util/read-after-write.ts similarity index 91% rename from packages/pds/src/app-view/api/app/bsky/util/read-after-write.ts rename to packages/pds/src/api/app/bsky/util/read-after-write.ts index b09a30cd2a1..b834a91c1b7 100644 --- a/packages/pds/src/app-view/api/app/bsky/util/read-after-write.ts +++ b/packages/pds/src/api/app/bsky/util/read-after-write.ts @@ -1,7 +1,7 @@ import { Headers } from '@atproto/xrpc' -import { readStickyLogger as log } from '../../../../../logger' -import { LocalRecords } from '../../../../../services/local' -import AppContext from '../../../../../context' +import { readStickyLogger as log } from '../../../../logger' +import { LocalRecords } from '../../../../services/local' +import AppContext from '../../../../context' export type ApiRes = { headers: Headers diff --git a/packages/pds/src/app-view/api/app/bsky/util/resolver.ts b/packages/pds/src/api/app/bsky/util/resolver.ts similarity index 93% rename from packages/pds/src/app-view/api/app/bsky/util/resolver.ts rename to packages/pds/src/api/app/bsky/util/resolver.ts index 9be31998439..eac4f916424 100644 --- a/packages/pds/src/app-view/api/app/bsky/util/resolver.ts +++ b/packages/pds/src/api/app/bsky/util/resolver.ts @@ -1,5 +1,5 @@ import { DidDocument, PoorlyFormattedDidDocumentError } from '@atproto/identity' -import AppContext from '../../../../../context' +import AppContext from '../../../../context' import { InvalidRequestError } from '@atproto/xrpc-server' // provides http-friendly errors during did resolution diff --git a/packages/pds/src/app-view/api/app/bsky/index.ts b/packages/pds/src/app-view/api/app/bsky/index.ts deleted file mode 100644 index 69cf8432224..00000000000 --- a/packages/pds/src/app-view/api/app/bsky/index.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { Server } from '../../../../lexicon' -import AppContext from '../../../../context' -import getTimeline from './feed/getTimeline' -import getActorFeeds from './feed/getActorFeeds' -import getSuggestedFeeds from './feed/getSuggestedFeeds' -import getAuthorFeed from './feed/getAuthorFeed' -import getFeedGenerator from './feed/getFeedGenerator' -import getFeedGenerators from './feed/getFeedGenerators' -import getFeed from './feed/getFeed' -import getLikes from './feed/getLikes' -import getListFeed from './feed/getListFeed' -import getPostThread from './feed/getPostThread' -import getPosts from './feed/getPosts' -import getActorLikes from './feed/getActorLikes' -import getProfile from './actor/getProfile' -import getProfiles from './actor/getProfiles' -import getRepostedBy from './feed/getRepostedBy' -import getBlocks from './graph/getBlocks' -import getFollowers from './graph/getFollowers' -import getFollows from './graph/getFollows' -import getList from './graph/getList' -import getListBlocks from './graph/getListBlocks' -import getListMutes from './graph/getListMutes' -import getLists from './graph/getLists' -import getMutes from './graph/getMutes' -import muteActor from './graph/muteActor' -import muteActorList from './graph/muteActorList' -import unmuteActor from './graph/unmuteActor' -import unmuteActorList from './graph/unmuteActorList' -import getSuggestedFollowsByActor from './graph/getSuggestedFollowsByActor' -import getUsersSearch from './actor/searchActors' -import getUsersTypeahead from './actor/searchActorsTypeahead' -import getSuggestions from './actor/getSuggestions' -import listNotifications from './notification/listNotifications' -import getUnreadCount from './notification/getUnreadCount' -import updateSeen from './notification/updateSeen' -import registerPush from './notification/registerPush' -import unspecced from './unspecced' - -export default function (server: Server, ctx: AppContext) { - getTimeline(server, ctx) - getActorFeeds(server, ctx) - getSuggestedFeeds(server, ctx) - getAuthorFeed(server, ctx) - getFeedGenerator(server, ctx) - getFeedGenerators(server, ctx) - getFeed(server, ctx) - getLikes(server, ctx) - getListFeed(server, ctx) - getPostThread(server, ctx) - getPosts(server, ctx) - getActorLikes(server, ctx) - getProfile(server, ctx) - getProfiles(server, ctx) - getRepostedBy(server, ctx) - getBlocks(server, ctx) - getFollowers(server, ctx) - getFollows(server, ctx) - getList(server, ctx) - getListBlocks(server, ctx) - getListMutes(server, ctx) - getLists(server, ctx) - getMutes(server, ctx) - muteActor(server, ctx) - muteActorList(server, ctx) - unmuteActor(server, ctx) - unmuteActorList(server, ctx) - getSuggestedFollowsByActor(server, ctx) - getUsersSearch(server, ctx) - getUsersTypeahead(server, ctx) - getSuggestions(server, ctx) - listNotifications(server, ctx) - getUnreadCount(server, ctx) - updateSeen(server, ctx) - registerPush(server, ctx) - unspecced(server, ctx) -} diff --git a/packages/pds/src/app-view/api/app/bsky/unspecced.ts b/packages/pds/src/app-view/api/app/bsky/unspecced.ts deleted file mode 100644 index 8708b8fe92f..00000000000 --- a/packages/pds/src/app-view/api/app/bsky/unspecced.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { InvalidRequestError } from '@atproto/xrpc-server' -import { Server } from '../../../../lexicon' -import { GenericKeyset } from '../../../../db/pagination' -import AppContext from '../../../../context' - -// THIS IS A TEMPORARY UNSPECCED ROUTE -export default function (server: Server, ctx: AppContext) { - server.app.bsky.unspecced.getPopular({ - auth: ctx.accessVerifier, - handler: async ({ auth, params }) => { - const requester = auth.credentials.did - const HOT_CLASSIC_URI = - 'at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/hot-classic' - const HOT_CLASSIC_DID = 'did:plc:5fllqkujj6kqp5izd5jg7gox' - const res = await ctx.appviewAgent.api.app.bsky.feed.getFeed( - { feed: HOT_CLASSIC_URI, limit: params.limit, cursor: params.cursor }, - await ctx.serviceAuthHeaders(requester, HOT_CLASSIC_DID), - ) - return { - encoding: 'application/json', - body: res.data, - } - }, - }) - - server.app.bsky.unspecced.getPopularFeedGenerators({ - auth: ctx.accessVerifier, - handler: async ({ auth, params }) => { - const requester = auth.credentials.did - const res = - await ctx.appviewAgent.api.app.bsky.unspecced.getPopularFeedGenerators( - params, - await ctx.serviceAuthHeaders(requester), - ) - return { - encoding: 'application/json', - body: res.data, - } - }, - }) -} - -type Result = { likeCount: number; cid: string } -type LabeledResult = { primary: number; secondary: string } -export class LikeCountKeyset extends GenericKeyset { - labelResult(result: Result) { - return { - primary: result.likeCount, - secondary: result.cid, - } - } - labeledResultToCursor(labeled: LabeledResult) { - return { - primary: labeled.primary.toString(), - secondary: labeled.secondary, - } - } - cursorToLabeledResult(cursor: { primary: string; secondary: string }) { - const likes = parseInt(cursor.primary, 10) - if (isNaN(likes)) { - throw new InvalidRequestError('Malformed cursor') - } - return { - primary: likes, - secondary: cursor.secondary, - } - } -} diff --git a/packages/pds/src/app-view/api/index.ts b/packages/pds/src/app-view/api/index.ts deleted file mode 100644 index 1f963088637..00000000000 --- a/packages/pds/src/app-view/api/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Server } from '../../lexicon' -import appBsky from './app/bsky' -import AppContext from '../../context' - -export default function (server: Server, ctx: AppContext) { - appBsky(server, ctx) - return server -} diff --git a/packages/pds/src/app-view/logger.ts b/packages/pds/src/app-view/logger.ts deleted file mode 100644 index 57bca80b1e3..00000000000 --- a/packages/pds/src/app-view/logger.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { subsystemLogger } from '@atproto/common' - -export const appViewLogger = subsystemLogger('app-view') diff --git a/packages/pds/src/index.ts b/packages/pds/src/index.ts index fb08ef375e9..687ec9699af 100644 --- a/packages/pds/src/index.ts +++ b/packages/pds/src/index.ts @@ -21,7 +21,6 @@ import { Options as XrpcServerOptions, } from '@atproto/xrpc-server' import { DAY, HOUR, MINUTE } from '@atproto/common' -import inProcessAppView from './app-view/api' import API from './api' import * as basicRoutes from './basic-routes' import * as wellKnown from './well-known' @@ -219,7 +218,6 @@ export class PDS { let server = createServer(xrpcOpts) server = API(server, ctx) - server = inProcessAppView(server, ctx) app.use(basicRoutes.createRouter(ctx)) app.use(wellKnown.createRouter(ctx))