chore(deps): update pino (#63142)

This commit is contained in:
Oliver Eyton-Williams
2025-10-28 14:43:50 +01:00
committed by GitHub
parent 1146b74eb9
commit 2d04d11056
6 changed files with 160 additions and 50 deletions
+1 -1
View File
@@ -31,7 +31,7 @@
"nanoid": "3",
"no-profanity": "1.5.1",
"nodemailer": "6.9.10",
"pino": "^9.6.0",
"pino": "9.14.0",
"pino-pretty": "10.2.3",
"query-string": "7.1.3",
"stripe": "16.0.0",
@@ -28,9 +28,10 @@ export const dailyCodingChallengeRoutes: FastifyPluginCallbackTypebox = (
},
async (req, reply) => {
const logger = fastify.log.child({ req, res: reply });
logger.info('Received request for daily coding challenge', {
date: req.params.date
});
logger.info(
{ date: req.params.date },
'Received request for daily coding challenge'
);
const { date } = req.params;
@@ -38,7 +39,7 @@ export const dailyCodingChallengeRoutes: FastifyPluginCallbackTypebox = (
const parsedDate = dateStringToUtcMidnight(date);
if (!parsedDate) {
logger.warn('Invalid date format requested', { date });
logger.warn({ date }, 'Invalid date format requested');
return reply.status(400).send({
type: 'error',
message: 'Invalid date format. Please use YYYY-MM-DD.'
@@ -53,7 +54,7 @@ export const dailyCodingChallengeRoutes: FastifyPluginCallbackTypebox = (
// don't return challenges > today US Central
if (!challenge || challenge.date > getUtcMidnight(getNowUsCentral())) {
logger.warn('Challenge not found for date', { date: parsedDate });
logger.warn({ date: parsedDate }, 'Challenge not found for date');
return reply
.status(404)
.send({ type: 'error', message: 'Challenge not found.' });
@@ -92,7 +93,7 @@ export const dailyCodingChallengeRoutes: FastifyPluginCallbackTypebox = (
});
if (!todaysChallenge) {
logger.warn('Challenge not found for today', { date: today });
logger.warn({ date: today }, 'Challenge not found for today');
return reply
.status(404)
.send({ type: 'error', message: 'Challenge not found.' });
@@ -118,9 +119,10 @@ export const dailyCodingChallengeRoutes: FastifyPluginCallbackTypebox = (
},
async (req, reply) => {
const logger = fastify.log.child({ req, res: reply });
logger.info('Received request for month of daily coding challenges', {
month: req.params.month
});
logger.info(
{ month: req.params.month },
'Received request for month of daily coding challenges'
);
const { month } = req.params;
@@ -132,7 +134,7 @@ export const dailyCodingChallengeRoutes: FastifyPluginCallbackTypebox = (
// Validate month range
if (parsedMonth < 1 || parsedMonth > 12) {
logger.warn('Invalid month value requested', { month });
logger.warn({ month }, 'Invalid month value requested');
return reply.status(400).send({
type: 'error',
message: 'Invalid date format. Please use YYYY-MM.'
@@ -163,7 +165,7 @@ export const dailyCodingChallengeRoutes: FastifyPluginCallbackTypebox = (
});
if (!challenges || challenges.length === 0) {
logger.warn('No challenges found for month', { month });
logger.warn({ month }, 'No challenges found for month');
return reply
.status(404)
.send({ type: 'error', message: 'No challenges found.' });
@@ -216,7 +218,7 @@ export const dailyCodingChallengeRoutes: FastifyPluginCallbackTypebox = (
});
if (!allChallenges || allChallenges.length === 0) {
logger.warn('No challenges found.', { date: today });
logger.warn({ date: today }, 'No challenges found.');
return reply
.status(404)
.send({ type: 'error', message: 'No challenges found.' });
+14 -11
View File
@@ -123,32 +123,35 @@ export const chargeStripeRoute: FastifyPluginCallbackTypebox = (
const isValidCustomer = typeof subscription.customer === 'string';
if (!isSubscriptionActive) {
log.warn('Invalid subscription status', {
status: subscription.status
});
log.warn(
{ status: subscription.status },
'Invalid subscription status'
);
throw new Error(
`Stripe subscription information is invalid: ${subscriptionId}`
);
}
if (!isProductIdValid) {
log.warn('Invalid product ID', { productId });
log.warn({ productId }, 'Invalid product ID');
throw new Error(`Product ID is invalid: ${subscriptionId}`);
}
if (!isStartedRecently) {
log.warn('Subscription not recent', {
startTime: subscription.current_period_start
});
log.warn(
{ startTime: subscription.current_period_start },
'Subscription not recent'
);
throw new Error(`Subscription is not recent: ${subscriptionId}`);
}
if (!isValidCustomer) {
log.warn('Invalid customer ID', {
customerId: subscription.customer
});
log.warn(
{ customerId: subscription.customer },
'Invalid customer ID'
);
throw new Error(`Customer ID is invalid: ${subscriptionId}`);
}
const user = await findOrCreateUser(fastify, email);
log.debug('Found or created user', { userId: user.id });
log.debug({ userId: user.id }, 'Found or created user');
const donation = {
userId: user.id,
+1 -1
View File
@@ -16,7 +16,7 @@ export const statusRoute: FastifyPluginCallbackTypebox = (
done
) => {
fastify.get('/status/ping', async (req, res) => {
fastify.log.child({ req, res }).debug('Replying to ping');
fastify.log.child({ req, res }).debug({ what: 'pong' }, 'Replying to ping');
return { msg: 'pong' };
});
+7 -5
View File
@@ -3,10 +3,11 @@ import { FastifyRequest, FastifyReply } from 'fastify';
import { isEmpty } from 'lodash-es';
import type {
TransportTargetOptions,
DestinationStream,
LoggerOptions
// DestinationStream,
LoggerOptions,
DestinationStream
} from 'pino';
import { pino } from 'pino';
import { pino, transport } from 'pino';
import { FCC_API_LOG_LEVEL, FCC_API_LOG_TRANSPORT } from './env.js';
const serializers = {
@@ -99,10 +100,11 @@ export const getLogger = () => {
};
if (isPretty) {
const transport = pino.transport({ targets: [prettyTarget] }) as
const stream = transport({ targets: [prettyTarget] }) as
| DestinationStream
| undefined;
return pino(options, transport);
return pino(options, stream);
} else {
// For non-pretty, use the custom de-duplicating transform stream
// This logger will write to a stream that then pipes to our de-duplicator