-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NONE: Update our webhook route to send a status code back immediately (…
…#207) * NONE: Update our webhook route to send a status code back immediately * update integration tests * lol finish writing comments about whats going on w jest * address comments
- Loading branch information
Showing
8 changed files
with
85 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { EventEmitter } from 'events'; | ||
|
||
export const eventBus = new EventEmitter(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './logger'; | ||
export * from './event-bus'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { eventBus } from '../event-bus'; | ||
|
||
export function waitForEvent(eventName: string): Promise<void> { | ||
return new Promise((resolve) => { | ||
eventBus.once(eventName, resolve); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './event-bus-utils'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { FigmaTeam } from '../domain/entities'; | ||
import { eventBus, getLogger } from '../infrastructure'; | ||
import { handleFigmaFileUpdateEventUseCase } from '../usecases'; | ||
import type { FigmaFileUpdateWebhookEventRequestBody } from '../web/routes/figma'; | ||
|
||
export const handleFigmaFileUpdateEvent = async ( | ||
requestBody: FigmaFileUpdateWebhookEventRequestBody, | ||
figmaTeam: FigmaTeam, | ||
): Promise<void> => { | ||
const { file_key: fileKey, webhook_id: webhookId } = requestBody; | ||
try { | ||
await handleFigmaFileUpdateEventUseCase.execute(figmaTeam, fileKey); | ||
|
||
getLogger().info({ webhookId }, 'Figma webhook callback succeeded.'); | ||
eventBus.emit('figma.webhook.succeeded', { webhookId }); | ||
} catch (e) { | ||
getLogger().error(e, 'Figma webhook callback failed.', { | ||
webhookId, | ||
}); | ||
eventBus.emit('figma.webhook.failed', { webhookId }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './handle-figma-file-update-event'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters