Skip to content

Commit

Permalink
fix: initialize only once
Browse files Browse the repository at this point in the history
  • Loading branch information
whilefoo committed Nov 19, 2023
1 parent db19706 commit df8bc59
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/bindings/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ type AllHandlers = PreActionHandler | MainActionHandler | PostActionHandler;

const validatePayload = ajv.compile(PayloadSchema);

export async function bindEvents(eventContext: ProbotContext) {
const runtime = Runtime.getState();
runtime.adapters = createAdapters();
runtime.logger = runtime.adapters.supabase.logs;
const runtime = Runtime.getState();
runtime.adapters = createAdapters();
runtime.logger = runtime.adapters.supabase.logs;

export async function bindEvents(eventContext: ProbotContext) {
const payload = eventContext.payload as Payload;
const eventName = payload?.action ? `${eventContext.name}.${payload?.action}` : eventContext.name; // some events wont have actions as this grows

Expand Down
4 changes: 1 addition & 3 deletions src/handlers/processors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import Runtime from "../bindings/bot-runtime";
* TODO: all MUST receive `Context` as the only parameter
*/

const runtime = Runtime.getState();

export const processors: Record<string, Handler> = {
[GitHubEvent.ISSUES_OPENED]: {
pre: [],
Expand All @@ -29,7 +27,7 @@ export const processors: Record<string, Handler> = {
},
[GitHubEvent.ISSUES_REOPENED]: {
pre: [],
action: [async () => runtime.logger.debug(null, "TODO: replace ISSUES_REOPENED handler")],
action: [async () => Runtime.getState().logger.debug(null, "TODO: replace ISSUES_REOPENED handler")],
post: [],
},
[GitHubEvent.ISSUES_LABELED]: {
Expand Down

0 comments on commit df8bc59

Please sign in to comment.