express-prismic
Advanced tools
Comparing version 0.0.3 to 0.0.4
38
index.js
@@ -79,22 +79,24 @@ var Prismic = require('prismic.io').Prismic, | ||
var ctxPromise = new Promise(function (fulfill) { | ||
exports.getApiHome(accessToken, function(err, Api) { | ||
if (!configuration.linkResolver) { | ||
throw new Error("Missing linkResolver in configuration: make sure to call init() at the beginning of your script"); | ||
} | ||
if (err) { | ||
exports.onPrismicError(err, req, res); | ||
try { | ||
exports.getApiHome(accessToken, function(err, Api) { | ||
if (!configuration.linkResolver) { | ||
throw new Error("Missing linkResolver in configuration: make sure to call init() at the beginning of your script"); | ||
} | ||
if (err) { | ||
configuration.onPrismicError && configuration.onPrismicError(err, req, res); | ||
return; | ||
} | ||
var ctx = { | ||
endpoint: configuration.apiEndpoint, | ||
api: Api, | ||
ref: req.cookies[Prismic.experimentCookie] || req.cookies[Prismic.previewCookie] || Api.master(), | ||
linkResolver: function(doc) { | ||
return configuration.linkResolver(doc); | ||
} | ||
}; | ||
fulfill(ctx); | ||
}); | ||
var ctx = { | ||
endpoint: configuration.apiEndpoint, | ||
api: Api, | ||
ref: req.cookies[Prismic.experimentCookie] || req.cookies[Prismic.previewCookie] || Api.master(), | ||
linkResolver: function(doc) { | ||
return configuration.linkResolver(doc); | ||
} | ||
}; | ||
fulfill(ctx); | ||
}); | ||
} catch (ex) { | ||
return fulfill(ex); | ||
} | ||
}); | ||
@@ -101,0 +103,0 @@ if(callback){ |
{ | ||
"name": "express-prismic", | ||
"description": "Prismic.io support for Prismic.io", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "homepage": "http://github.com/prismicio/express-prismic", |
16335
115