mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
feat: add more api logs (#1870)
Adds more detailed API logging using Pino
This commit is contained in:
@ -67,6 +67,12 @@ export const templateRouter = router({
|
||||
.query(async ({ input, ctx }) => {
|
||||
const { teamId } = ctx;
|
||||
|
||||
ctx.logger.info({
|
||||
input: {
|
||||
folderId: input.folderId,
|
||||
},
|
||||
});
|
||||
|
||||
return await findTemplates({
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
@ -92,6 +98,12 @@ export const templateRouter = router({
|
||||
const { teamId } = ctx;
|
||||
const { templateId } = input;
|
||||
|
||||
ctx.logger.info({
|
||||
input: {
|
||||
templateId,
|
||||
},
|
||||
});
|
||||
|
||||
return await getTemplateById({
|
||||
id: templateId,
|
||||
userId: ctx.user.id,
|
||||
@ -120,6 +132,12 @@ export const templateRouter = router({
|
||||
const { teamId } = ctx;
|
||||
const { title, templateDocumentDataId, folderId } = input;
|
||||
|
||||
ctx.logger.info({
|
||||
input: {
|
||||
folderId,
|
||||
},
|
||||
});
|
||||
|
||||
return await createTemplate({
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
@ -146,9 +164,14 @@ export const templateRouter = router({
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
const { teamId } = ctx;
|
||||
const { templateId, data, meta } = input;
|
||||
|
||||
const userId = ctx.user.id;
|
||||
|
||||
ctx.logger.info({
|
||||
input: {
|
||||
templateId,
|
||||
},
|
||||
});
|
||||
|
||||
return await updateTemplate({
|
||||
userId,
|
||||
teamId,
|
||||
@ -176,6 +199,12 @@ export const templateRouter = router({
|
||||
const { teamId } = ctx;
|
||||
const { templateId } = input;
|
||||
|
||||
ctx.logger.info({
|
||||
input: {
|
||||
templateId,
|
||||
},
|
||||
});
|
||||
|
||||
return await duplicateTemplate({
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
@ -200,9 +229,14 @@ export const templateRouter = router({
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
const { teamId } = ctx;
|
||||
const { templateId } = input;
|
||||
|
||||
const userId = ctx.user.id;
|
||||
|
||||
ctx.logger.info({
|
||||
input: {
|
||||
templateId,
|
||||
},
|
||||
});
|
||||
|
||||
await deleteTemplate({ userId, id: templateId, teamId });
|
||||
|
||||
return ZGenericSuccessResponse;
|
||||
@ -228,6 +262,12 @@ export const templateRouter = router({
|
||||
const { templateId, recipients, distributeDocument, customDocumentDataId, prefillFields } =
|
||||
input;
|
||||
|
||||
ctx.logger.info({
|
||||
input: {
|
||||
templateId,
|
||||
},
|
||||
});
|
||||
|
||||
const limits = await getServerLimits({ userId: ctx.user.id, teamId });
|
||||
|
||||
if (limits.remaining.documents === 0) {
|
||||
@ -291,6 +331,12 @@ export const templateRouter = router({
|
||||
templateUpdatedAt,
|
||||
} = input;
|
||||
|
||||
ctx.logger.info({
|
||||
input: {
|
||||
directTemplateToken,
|
||||
},
|
||||
});
|
||||
|
||||
return await createDocumentFromDirectTemplate({
|
||||
directRecipientName,
|
||||
directRecipientEmail,
|
||||
@ -330,6 +376,13 @@ export const templateRouter = router({
|
||||
|
||||
const userId = ctx.user.id;
|
||||
|
||||
ctx.logger.info({
|
||||
input: {
|
||||
templateId,
|
||||
directRecipientId,
|
||||
},
|
||||
});
|
||||
|
||||
const template = await getTemplateById({ id: templateId, teamId, userId: ctx.user.id });
|
||||
|
||||
const limits = await getServerLimits({ userId: ctx.user.id, teamId: template.teamId });
|
||||
@ -364,6 +417,12 @@ export const templateRouter = router({
|
||||
|
||||
const userId = ctx.user.id;
|
||||
|
||||
ctx.logger.info({
|
||||
input: {
|
||||
templateId,
|
||||
},
|
||||
});
|
||||
|
||||
await deleteTemplateDirectLink({ userId, teamId, templateId });
|
||||
|
||||
return ZGenericSuccessResponse;
|
||||
@ -390,6 +449,12 @@ export const templateRouter = router({
|
||||
|
||||
const userId = ctx.user.id;
|
||||
|
||||
ctx.logger.info({
|
||||
input: {
|
||||
templateId,
|
||||
},
|
||||
});
|
||||
|
||||
return await toggleTemplateDirectLink({ userId, teamId, templateId, enabled });
|
||||
}),
|
||||
|
||||
@ -402,6 +467,13 @@ export const templateRouter = router({
|
||||
const { templateId, teamId, csv, sendImmediately } = input;
|
||||
const { user } = ctx;
|
||||
|
||||
ctx.logger.info({
|
||||
input: {
|
||||
templateId,
|
||||
teamId,
|
||||
},
|
||||
});
|
||||
|
||||
if (csv.length > 4 * 1024 * 1024) {
|
||||
throw new TRPCError({
|
||||
code: 'BAD_REQUEST',
|
||||
|
||||
Reference in New Issue
Block a user