Skip to content

Commit

Permalink
Log warning messages if deprecated APIs are called
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Apr 23, 2024
1 parent 0651af7 commit 088024b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/manual/log.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ The `["fedify", "federation", "outbox"]` category is used for logging messages
related to outgoing activities. When you cannot send an activity, you can
check the log messages in this category with the `"debug"` level.

### `["fedify", "x", "fresh"]`

The `["fedify", "x", "fresh"]` category is used for logging messages related
to the `@fedify/fedify/x/fresh` module.


Sinks
-----
Expand Down
3 changes: 3 additions & 0 deletions federation/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,9 @@ export class Federation<TContextData> {
request: Request,
options: FederationFetchOptions<TContextData>,
): Promise<Response> {
getLogger(["fedify", "federation"]).warn(
"Federation.handle() is deprecated. Use Federation.fetch() instead.",
);
return this.fetch(request, options);
}

Expand Down
13 changes: 11 additions & 2 deletions x/fresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* @module
* @since 0.4.0
*/
import { getLogger } from "@logtape/logtape";
import type {
Federation,
FederationFetchOptions,
Expand Down Expand Up @@ -75,9 +76,17 @@ export function integrateFetchOptions(
*
* @param context A Fresh context.
* @returns Options for the {@link Federation.handle} method.
* @deprecated
* @deprecated Use {@link integrateFetchOptions} instead.
*/
export const integrateHandlerOptions = integrateFetchOptions;
export function integrateHandlerOptions(
context: FreshContext,
): Omit<FederationFetchOptions<void>, "contextData"> {
getLogger(["fedify", "x", "fresh"]).warn(
"The integrateHandlerOptions() is deprecated. " +
"Use the integrateFetchOptions() instead.",
);
return integrateFetchOptions(context);
}

/**
* Create a Fresh middleware handler to integrate with the {@link Federation}
Expand Down

0 comments on commit 088024b

Please sign in to comment.