Skip to content

Instantly share code, notes, and snippets.

@bmelnychuk
Last active August 15, 2018 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmelnychuk/a2d9684cac331aec77fe328cd9fe6923 to your computer and use it in GitHub Desktop.
Save bmelnychuk/a2d9684cac331aec77fe328cd9fe6923 to your computer and use it in GitHub Desktop.
import { getQuestions, getQuestion } from '../../../question-store';
export default class QuestionStoreRepository implements QuestionRepository {
async getAvailableQuestions(categoryId: string): Promise<Question[]> {
const rawQuestions = await getQuestions(categoryId);
return rawQuestions.map(rawQuestion => new Question(
rawQuestion.id,
rawQuestion.question,
rawQuestion.answer
));
}
async getById(questionId: string): Promise<Question> {
const rawQuestion = await getQuestion(questionId);
return new Question(
rawQuestion.id,
rawQuestion.question,
rawQuestion.answer
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment