import { setupEndpointsAuth } from "./endpoints/auth.js";
import { setupEndpointsAccount } from "./endpoints/account.js";
import { setupEndpointsStatus } from "./endpoints/status.js";
import { setupEndpointsFilter } from "./endpoints/filter.js";
import { setupEndpointsTimeline } from "./endpoints/timeline.js";
import { setupEndpointsNotifications } from "./endpoints/notifications.js";
import { setupEndpointsSearch } from "./endpoints/search.js";
import { setupEndpointsMedia } from "./endpoints/media.js";
import { setupEndpointsMisc } from "./endpoints/misc.js";
import { setupEndpointsList } from "./endpoints/list.js";
import { AuthMiddleware } from "./middleware/auth.js";
import { CatchErrorsMiddleware } from "./middleware/catch-errors.js";
import { apiLogger } from "../logger.js";
import { CacheMiddleware } from "./middleware/cache.js";
import { KoaBodyMiddleware } from "./middleware/koa-body.js";
import { NormalizeQueryMiddleware } from "./middleware/normalize-query.js";
import { PaginationMiddleware } from "./middleware/pagination.js";
import { SetHeadersMiddleware } from "./middleware/set-headers.js";
import { UserHelpers } from "./helpers/user.js";
import { setupEndpointsStreaming } from "./endpoints/streaming.js";
export const logger = apiLogger.createSubLogger("mastodon");
export function setupMastodonApi(router) {
    setupMiddleware(router);
    setupEndpointsAuth(router);
    setupEndpointsAccount(router);
    setupEndpointsStatus(router);
    setupEndpointsFilter(router);
    setupEndpointsTimeline(router);
    setupEndpointsNotifications(router);
    setupEndpointsStreaming(router);
    setupEndpointsSearch(router);
    setupEndpointsMedia(router);
    setupEndpointsList(router);
    setupEndpointsMisc(router);
}
function setupMiddleware(router) {
    router.use(KoaBodyMiddleware());
    router.use(SetHeadersMiddleware);
    router.use(CatchErrorsMiddleware);
    router.use(NormalizeQueryMiddleware);
    router.use(PaginationMiddleware);
    router.use(AuthMiddleware);
    router.use(CacheMiddleware);
}
export function getStubMastoContext(user, filterContext) {
    return {
        user: user ?? null,
        cache: UserHelpers.getFreshAccountCache(),
        filterContext: filterContext
    };
}
