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