fix: missing tools on a composable handler

This commit is contained in:
41666 2021-08-07 18:05:34 -04:00
parent 76a03c2d2c
commit d5acea4abb

View file

@ -17,7 +17,7 @@ import {
SessionData,
UserGuildPermissions,
} from '@roleypoly/types';
import { AuthType, discordFetch, Handler } from '@roleypoly/worker-utils';
import { AuthType, discordFetch, Handler, HandlerTools } from '@roleypoly/worker-utils';
import { cacheLayer, CacheLayerOptions, isRoot, withSession } from './api-tools';
import { botClientID, botToken } from './config';
import { GuildData, Guilds } from './kv';
@ -229,7 +229,9 @@ export const asEditor = (
options: AsEditorOptions = {},
wrappedHandler: (session: SessionData, userGuildContext: UserGuildContext) => Handler
): Handler =>
withSession((session: SessionData) => async (request: Request): Promise<Response> => {
withSession(
(session: SessionData) =>
async (request: Request, tools: HandlerTools): Promise<Response> => {
const { rateLimitKey, rateLimitTimeoutSeconds } = options;
const url = new URL(request.url);
const [, , guildID] = url.pathname.split('/');
@ -282,5 +284,6 @@ export const asEditor = (
guildID,
guild,
url,
})(request);
});
})(request, tools);
}
);