spf-express
Express middleware for youtube's SPF framework.
Framework documentation can be found here
Features
- Intercept requests with custom SPF query identifiers
- Attach SPF response objects or custom express handler to desired path
Installation
npm install spf-express
To run tests:
npm test
API
//returns an express middleware function
Options:
- paths: Object
- Key value can either be a SPF response object or an express middleware function
- Will return the corresponding response object or forward request to middleware when a SPF request is sent to a defined path.
- identifiers: [String]
- default: ["navigate", "prefetch", "navigate-back"]
- Extends on the default valid SPF request identifiers on the "spf" query field
- if the "spf" query field in a request contains a value in this field, it will be treated as a valid SPF request.
- override: Boolean
- default: False
- will override default list of SPF request identifiers with those set in the "identifiers" field if set to True.
Examples
Simple example
var spf_express = express = app = app
More on SPF response objects here
Advanced example
app
Example project
$ git clone https://github.com/Arthelon/spf-express.git
$ cd spf-express
$ npm install --dev
$ npm run start-example