mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-18 02:21:47 -05:00
Improved logging for members-api
no-issue This allows the logger to be passed in, and configures stripe to have access to it
This commit is contained in:
parent
80f1155590
commit
1c3e563ad7
2 changed files with 11 additions and 7 deletions
|
@ -28,8 +28,13 @@ module.exports = function MembersApi({
|
|||
getMember,
|
||||
updateMember,
|
||||
deleteMember,
|
||||
listMembers
|
||||
listMembers,
|
||||
logger
|
||||
}) {
|
||||
if (logger) {
|
||||
common.logging.setLogger(logger);
|
||||
}
|
||||
|
||||
const {encodeIdentityToken, decodeToken} = Tokens({privateKey, publicKey, issuer});
|
||||
|
||||
const stripeStorage = {
|
||||
|
@ -40,7 +45,7 @@ module.exports = function MembersApi({
|
|||
return setMemberMetadata(member, 'stripe', metadata);
|
||||
}
|
||||
};
|
||||
const stripe = paymentConfig.stripe ? new StripePaymentProcessor(paymentConfig.stripe, stripeStorage) : null;
|
||||
const stripe = paymentConfig.stripe ? new StripePaymentProcessor(paymentConfig.stripe, stripeStorage, common.logging) : null;
|
||||
|
||||
async function ensureStripe(_req, res, next) {
|
||||
if (!stripe) {
|
||||
|
@ -187,8 +192,6 @@ module.exports = function MembersApi({
|
|||
}
|
||||
});
|
||||
|
||||
const setLogger = common.logging.setLogger;
|
||||
|
||||
const getPublicConfig = function () {
|
||||
return Promise.resolve({
|
||||
publicKey,
|
||||
|
@ -213,7 +216,6 @@ module.exports = function MembersApi({
|
|||
getMemberDataFromMagicLinkToken,
|
||||
getMemberIdentityToken,
|
||||
getMemberIdentityData,
|
||||
setLogger,
|
||||
getPublicConfig,
|
||||
bus,
|
||||
members: users
|
||||
|
|
|
@ -5,7 +5,8 @@ const api = require('./api');
|
|||
const STRIPE_API_VERSION = '2019-09-09';
|
||||
|
||||
module.exports = class StripePaymentProcessor {
|
||||
constructor(config, storage) {
|
||||
constructor(config, storage, logging) {
|
||||
this.logging = logging;
|
||||
this.storage = storage;
|
||||
this._ready = new Promise((resolve, reject) => {
|
||||
this._resolveReady = resolve;
|
||||
|
@ -57,9 +58,10 @@ module.exports = class StripePaymentProcessor {
|
|||
});
|
||||
this._webhookSecret = webhook.secret;
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
this.logging.warn(err);
|
||||
this._webhookSecret = process.env.WEBHOOK_SECRET;
|
||||
}
|
||||
this.logging.info(this._webhookSecret);
|
||||
} catch (err) {
|
||||
return this._rejectReady(err);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue