Unverified Commit 1d26571c authored by Hong Minhee's avatar Hong Minhee
Browse files

Update dispatcher & listener setters to use type-safe path format

parent 8cb8c8e9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -37,6 +37,10 @@ To be released.

 -  Activity Vocabulary classes now have `typeId` static property.

 -  Dispatcher setters and inbox listener setters in `Federation` now take
    a path as <code>`${string}{handle}${string}`</code> instead of `string`
    so that it is more type-safe.

[public addressing]: https://www.w3.org/TR/activitypub/#public-addressing
[authorized fetch]: https://swicg.github.io/activitypub-http-signature/#authorized-fetch
[LogTape]: https://github.com/dahlia/logtape
+5 −5
Original line number Diff line number Diff line
@@ -523,7 +523,7 @@ export class Federation<TContextData> {
   * @throws {RouterError} Thrown if the path pattern is invalid.
   */
  setActorDispatcher(
    path: string,
    path: `${string}{handle}${string}`,
    dispatcher: ActorDispatcher<TContextData>,
  ): ActorCallbackSetters<TContextData> {
    if (this.#router.has("actor")) {
@@ -574,7 +574,7 @@ export class Federation<TContextData> {
   * @throws {@link RouterError} Thrown if the path pattern is invalid.
   */
  setOutboxDispatcher(
    path: string,
    path: `${string}{handle}${string}`,
    dispatcher: CollectionDispatcher<Activity, TContextData>,
  ): CollectionCallbackSetters<TContextData> {
    if (this.#router.has("outbox")) {
@@ -623,7 +623,7 @@ export class Federation<TContextData> {
   * @throws {RouterError} Thrown if the path pattern is invalid.
   */
  setFollowingDispatcher(
    path: string,
    path: `${string}{handle}${string}`,
    dispatcher: CollectionDispatcher<Actor | URL, TContextData>,
  ): CollectionCallbackSetters<TContextData> {
    if (this.#router.has("following")) {
@@ -672,7 +672,7 @@ export class Federation<TContextData> {
   * @throws {@link RouterError} Thrown if the path pattern is invalid.
   */
  setFollowersDispatcher(
    path: string,
    path: `${string}{handle}${string}`,
    dispatcher: CollectionDispatcher<Actor | URL, TContextData>,
  ): CollectionCallbackSetters<TContextData> {
    if (this.#router.has("followers")) {
@@ -739,7 +739,7 @@ export class Federation<TContextData> {
   * @throws {RouteError} Thrown if the path pattern is invalid.
   */
  setInboxListeners(
    inboxPath: string,
    inboxPath: `${string}{handle}${string}`,
    sharedInboxPath?: string,
  ): InboxListenerSetter<TContextData> {
    if (this.#router.has("inbox")) {