mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-19 00:11:49 +03:00
6f6c8f4521
refs #9178 - avoid importing 4 modules (logging, errors, events and i18n) - simply require common in each file
30 lines
803 B
JavaScript
30 lines
803 B
JavaScript
var api = require('../../api'),
|
|
labs = require('../../utils/labs'),
|
|
common = require('../../lib/common');
|
|
|
|
module.exports = function getFrontendClient(req, res, next) {
|
|
if (labs.isSet('publicAPI') !== true) {
|
|
return next();
|
|
}
|
|
|
|
return api.clients
|
|
.read({slug: 'ghost-frontend'})
|
|
.then(function handleClient(client) {
|
|
client = client.clients[0];
|
|
|
|
if (client.status === 'enabled') {
|
|
res.locals.client = {
|
|
id: client.slug,
|
|
secret: client.secret
|
|
};
|
|
}
|
|
|
|
next();
|
|
})
|
|
.catch(function (err) {
|
|
// Log the error, but carry on as this is non-critical
|
|
common.logging.error(err);
|
|
next();
|
|
});
|
|
};
|