libflitter/templates/middleware.js

/**
 * @module libflitter/templates/middleware
 */

/**
 * Get the contents of a new middleware definition file with the specified class name.
 * @param {string} name - the name of the Middleware's class
 * @returns {string}
 */
module.exports = exports = (name) => {
    return `/*
 * ${name} Middleware
 * -------------------------------------------------------------
 * Put some description here!
 */
class ${name} {

    /*
     * Run the middleware test.
     * This method is required by all Flitter middleware.
     * It should either call the next function in the stack,
     * or it should handle the response accordingly.
     */
    test(req, res, next, args = {}){
        console.log("Do stuff here!")

        /*
         * Call the next function in the stack.
         */
        next()
    }
}

module.exports = ${name}`
}