NestJS module containing Questions REST API endpoints for Quiz application.
Table of Contents:
- Retrieve a list of quiz questions
- Retrieve a list of quiz topics
- Create a new quiz question
- Update a quiz question
- Delete a quiz question by id
- Create new quiz questions
${\textsf{\color{lightgreen}GET}}$ https://{host}/quiz/questions
Param | Type | Required | Description | Example |
---|---|---|---|---|
topics[] | string | false | The topics to filter questions by | HTML |
count | number | false | The number of questions to retrieve | 10 |
[
{
topic: string;
text: string;
code?: {
text: string;
language: 'typescript' | 'javascript' | 'html' | 'css';
}
options: string[];
answer: {
index: number;
explanation?: string;
};
meta?: {
reviewed?: boolean;
difficult?: 'easy' | 'medium' | 'hard';
}
}
]
[!TIP] To filter by multiple topics, use a few "topics[]" query parameters. For example:
/quiz/questions?topics[]=HTML&topics[]=CSS
${\textsf{\color{lightgreen}GET}}$ https://{host}/quiz/topics
[
{
name: string;
questionCount: number;
}
]
${\textsf{\color{orange}POST}}$ https://{host}/quiz/question
{
topic: string;
text: string;
code?: {
text: string;
language: 'typescript' | 'javascript' | 'html' | 'css';
}
options: string[];
answer: {
index: number;
explanation?: string;
};
meta?: {
reviewed?: boolean;
difficult?: 'easy' | 'medium' | 'hard';
}
}
${\textsf{\color{blue}PUT}}$ https://{host}/quiz/question
{
_id: string;
topic: string;
text: string;
code?: {
text: string;
language: 'typescript' | 'javascript' | 'html' | 'css';
}
options: string[];
answer: {
index: number;
explanation?: string;
};
meta?: {
reviewed?: boolean;
difficult?: 'easy' | 'medium' | 'hard';
}
}
${\textsf{\color{red}DELETE}}$ https://{host}/quiz/question
Param | Type | Required | Description | Example |
---|---|---|---|---|
id | string | true | Question ID to delete | 671438511204ca5ad9df5366 |
${\textsf{\color{orange}POST}}$ https://{host}/quiz/questions
[
{
topic: string;
text: string;
code?: {
text: string;
language: 'typescript' | 'javascript' | 'html' | 'css';
}
options: string[];
answer: {
index: number;
explanation?: string;
};
meta?: {
reviewed?: boolean;
difficult?: 'easy' | 'medium' | 'hard';
}
}
]
Install the package to the main NestJS application and add it to the main module imports:
import { QuestionsModule } from '@fellendorf/api-quiz-questions-module';
@Module({
imports: [QuestionsModule],
controllers: [],
providers: [],
})
[!IMPORTANT] Main application must be connected to the MongoDB database.
Repository contains an app module (src/_dev-only
) just for development purposes. Additionally:
- command
npm run build
is set to use this main module to develop the "Questions" module; - the folder containing the main module will not be included in the npm package (see
.npmignore
file)
[!NOTE] Using
npm link
command orfile://...
path in pacakge.json brings some bugs.
- TESTS