implemented logging

This commit is contained in:
Dobromir Popov
2024-04-25 18:54:47 +03:00
parent 14c06b6062
commit d28b82b1fa
4 changed files with 79 additions and 9 deletions

View File

@ -8,6 +8,8 @@ import { authOptions } from "../auth/[...nextauth]";
const common = require("../../../src/helpers/common");
import jwt from 'jsonwebtoken';
import { decode } from 'next-auth/jwt';
const logger = require('../../../src/logger');
// import { getToken } from "next-auth/jwt";
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
@ -25,6 +27,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const authHeader = req.headers.authorization || '';
//console.log('authHeader', authHeader);
if (session) {
//get target table
const targetTable = req.query.nextcrud[0];
//get target action
if (req.method === 'DELETE') {
const targetId = req.query.nextcrud[1];
logger.info('[nextCrud] ' + targetTable + ': ' + targetId + 'DELETED by ' + session.user.email);
}
return nextCrudHandler(req, res);
}
else {