A simple quizzes API server and Single Page Application powered by Nodejs, Expressjs, Vuejs and Redis.
Prerequisite : Populate the used redis db with some quizzes (alternative : use POST /quizzes API)
- Create a configured quizzy instance with Quizzy factory
- start() : starts the server
- stop() : closes the server
const Quizzy =
const quizzy =
- Play a quiz session with the SPA
- Sign in with your Google, Twitter, or Facebook account
- Create and manage quizzes and sessions via APIs
- i18n compliant
Anatomy of the project
Help about the project structure
Static assets (css, images, ...)
This directory contains all the Single Page Application code powered by Vuejs.
The client part is based on VueJS with vue-i18n, vue-router, and vuex (it can also be used as a boilerplate project for VueJS)
Vuejs used components
- style.css : styles applied to the single page app
- home.vue : welcome view displayed for default routes and when not logged in
- quiz.vue : main vue that shows quiz questions and post answers to API server
- quiz-result.vue : shows the quiz result with score and evaluation if enabled in config
This directory contains all the server code powered by Nodejs.
Contains all the routes exposed by the express app, including APIs and OAuth2 endpoints
Contains all the JSON schemas of entities, in YAML format.
- store : Used to store the data model (quizzes and sessions) into memory or redis (feel free to code another implementation)
- index.js : Generic store interface
- memory-store.js : Simple store implementation in-memory
- redis-store.js : Store implementation for a Redis database server
- body-parser.js : Extended body parser compatible with JSON or YAML payload
- errors.js : Custom error classes used in the project
- json-validator.js : JSON schema validator used by the store to validate entities before persist them
- redis-cli.js : A simple Redis client
- view-renderer.js : Custom HTML view renderer powered by lodash template
Main module of the app. It exports a server component with a factory, init, start and stop methods if required by another module else it runs the server.
Unit tests in the form of mocha specs
Expressjs views used to render HTML pages
The best way to understand how quizzy works is to have a look at unit tests
Build the project
Install dependencies :
Build the cli bundle :
- The bundle file is created into assets/app directory
- if NODE_ENV is set to production, the bundle is uglyfied/minified without sourcemaps.
Start the server :
Note : if NODE_ENV is set to development, the server is started with nodemon and webpack middleware is used to hot reload the cli.