atsid/express-jefferson

View on GitHub
src/domain/appsection/locals.js

Summary

Maintainability
A
0 mins
Test Coverage
const debug = require('debug')('jefferson:locals');

/**
 * Configures application locals, which are available to Templating engines:
 * http://expressjs.com/api.html#app.locals
 */
class Locals {
    constructor(app, conf) {
        this.app = app;
        this.conf = conf;
    }

    configure() {
        const locals = this.conf.locals;
        Object.keys(locals).forEach((key) => {
            const value = locals[key];
            debug(`defining local ${key} => ${typeof value}`);
            this.app.locals[key] = value;
        });
    }
}

module.exports = Locals;