express-prismic
Advanced tools
Comparing version 0.0.2 to 0.0.3
17
index.js
@@ -21,4 +21,2 @@ var Prismic = require('prismic.io').Prismic, | ||
exports.previewCookie = Prismic.previewCookie; | ||
function prismicWithCTX(ctxPromise, req, res) { | ||
@@ -111,1 +109,16 @@ var self = { | ||
exports.preview = function(req, res) { | ||
prismic.withContext(req,res, function then(ctx) { | ||
var token = req.query['token']; | ||
if (token) { | ||
ctx.api.previewSession(token, ctx.linkResolver, '/', function(err, url) { | ||
res.cookie(Prismic.previewCookie, token, { maxAge: 30 * 60 * 1000, path: '/', httpOnly: false }); | ||
res.redirect(301, url); | ||
}); | ||
} else { | ||
res.send(400, "Missing token from querystring"); | ||
} | ||
}); | ||
}; | ||
{ | ||
"name": "express-prismic", | ||
"description": "Prismic.io support for Prismic.io", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "homepage": "http://github.com/prismicio/express-prismic", |
16206
111