1.0.4 • Published 8 years ago

express-spf v1.0.4

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

express-spf

Express middleware for youtube's SPF

In development, please see the github repo for current progress

Todo

  • Rewrite and write everything

Usage:

use with express handlebars, place your views in the the views directory.

var express = require('express');
var expressSpf = require('express-spf');
var expressHbs = require('express-handlebars');

var app = express();
var hbs = expressHbs.create();
var spf = expressSpf.init(hbs);

app.engine('.hbs', hbs.engine);
app.set('view engine', '.hbs');
app.use(spf);

app.get('/', function (req, res) {

    //if the request has an spf query express-spf
    //will expose a method int response object.
    if (res.hasOwnProperty('spf')) {

        //Create a new spf response object
        var obj = spf.spfResponse(req);

        /*
        obj = {
            url: req.url
            attr: {}
            body: {}
            foot: null
            head: null
            title: null
        }
        */

        //set your values
        obj.title = "Inbox";

        //If you want to update an id with just a string
        obj.body['title'] = "Inbox";

        //If you want to update an id with an hbs layout
        obj.body['main-content'] = {
            inbox: { //hbs viewname
                helpers: { //hbs parameters
                    title: "Inbox"
                },
                authenticated: true,
                layout: null
            }
        };

        //return your response
        return res.spf(obj);
    }
});
1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago