express-spf
v1.0.4
Published
Express middleware for youtube's SPF
Downloads
12
Maintainers
Readme
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);
}
});