-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
command to debug. Split event handler
- Loading branch information
1 parent
b03020d
commit 5d1b25d
Showing
2 changed files
with
25 additions
and
2 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,17 @@ | ||
import { Command } from '@boostercloud/framework-core' | ||
import { Register, UUID } from '@boostercloud/framework-types' | ||
import { QuestionCreated } from '../events/question-created'; | ||
|
||
@Command({ | ||
authorize: 'all' // Specify authorized roles here. Use 'all' to authorize anyone | ||
}) | ||
export class PostQuestion { | ||
public constructor( | ||
readonly conferenceId: UUID, | ||
readonly text: string, | ||
) {} | ||
|
||
public static async handle(command: PostQuestion , register: Register): Promise<void> { | ||
register.events(new QuestionCreated(command.text, UUID.generate(), command.conferenceId)) | ||
} | ||
} |
10 changes: 8 additions & 2 deletions
10
asker-analytics/backend/src/event-handlers/split-questions-into-words.ts
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,8 +1,14 @@ | ||
import { QuestionCreated } from '../events/question-created' | ||
import { WordPicked } from '../events/word-picked' | ||
import { EventHandler } from '@boostercloud/framework-core' | ||
import { Register } from '@boostercloud/framework-types' | ||
import { Register, UUID } from '@boostercloud/framework-types' | ||
|
||
@EventHandler(QuestionCreated) | ||
export class SplitQuestionsIntoWords { | ||
public static async handle(event: QuestionCreated, register: Register): Promise<void> {} | ||
public static async handle(event: QuestionCreated, register: Register): Promise<void> { | ||
const words = event.text.split(' ') | ||
for (const word in words) { | ||
register.events(new WordPicked(word, UUID.generate(), event.id, event.conferenceId)) | ||
} | ||
} | ||
} |