Noisy Pneumatic Mnemonic

    quizzy

    0.3.9 • Public • Published

    NPM version Build Status Coverage Status npm

    Quizzy

    A simple quizzes API server and Single Page Application powered by Nodejs, Expressjs, Vuejs and Redis.

    Prerequisite

    Install NodeJS

    Install

    $ npm install quizzy

    or

    $ yarn add quizzy

    Usage

    Prerequisite : Populate the used redis db with some quizzes (alternative : use POST /quizzes API)

    1. Create a configured quizzy instance with Quizzy factory
    2. start() : starts the server
    3. stop() : closes the server
    const Quizzy = require('quizzy')
    const quizzy = Quizzy(/*myCustomConfig*/)
    quizzy.start()
      .then(() => {
        console.log('ready!')
      })

    Features :

    • 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

    assets

    Static assets (css, images, ...)

    cli

    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)

    components

    Vuejs used components

    css
    • style.css : styles applied to the single page app
    views

    Vuejs views

    • 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

    lib

    This directory contains all the server code powered by Nodejs.

    config
    routes

    Contains all the routes exposed by the express app, including APIs and OAuth2 endpoints

    schemas

    Contains all the JSON schemas of entities, in YAML format.

    services
    • 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
    config.js

    Configuration loader

    helper.js

    Util functions

    quizzy.js

    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.

    test

    Unit tests in the form of mocha specs

    views

    Expressjs views used to render HTML pages

    More information

    The best way to understand how quizzy works is to have a look at unit tests

    Build the project

    Install dependencies :

    $ npm install

    or

    $ yarn

    Build the cli bundle :

    $ npm run build

    Note :

    • 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 :

    $ npm start

    Note : if NODE_ENV is set to development, the server is started with nodemon and webpack middleware is used to hot reload the cli.

    @tocomplete

    Enjoy !

    Keywords

    none

    Install

    npm i quizzy

    DownloadsWeekly Downloads

    2

    Version

    0.3.9

    License

    MIT

    Last publish

    Collaborators

    • openhoat