Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-logger-service

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-logger-service - npm Package Compare versions

Comparing version 1.0.12 to 1.0.13

15

dist/spec/RequestLogger.spec.js

@@ -16,2 +16,7 @@ "use strict";

const nextFunction = () => { nextCalled = true; };
const responseMock = {
socket: {
finished: true,
},
};
beforeAll(() => __awaiter(this, void 0, void 0, function* () {

@@ -47,3 +52,3 @@ requestLogger = new index_1.RequestLogger();

beforeEach(() => {
requestLogger.logExpressRequest({ route: { path: '/mypath' } }, undefined, nextFunction);
requestLogger.logExpressRequest({ route: { path: '/mypath' } }, responseMock, nextFunction);
});

@@ -54,3 +59,11 @@ it('Should return without failing', () => {

});
describe('When path and method is defined', () => {
beforeEach(() => {
requestLogger.logExpressRequest({ route: { path: '/mypath' }, method: 'GET' }, responseMock, nextFunction);
});
it('Should return without failing', () => {
expect(nextCalled).toBeTruthy();
});
});
});
//# sourceMappingURL=RequestLogger.spec.js.map

2

dist/src/RequestLogger.d.ts
export declare class RequestLogger {
private readonly logger;
private static readonly LOGGER;
logExpressRequest(req: any, res: any, next: any): void;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const LoggerFactory_1 = require("./LoggerFactory");
const onFinished = require('on-finished');
class RequestLogger {
constructor() {
this.logger = LoggerFactory_1.LoggerFactory.createLogger(RequestLogger.name);
}
logExpressRequest(req, res, next) {
const requestPath = req && req.route && req.route.path;
if (!requestPath) {
this.logger.warn('No request path defined.');
RequestLogger.LOGGER.warn('No request path defined.');
next();
return;
}
this.logger.info(`Before request '${requestPath}'`);
const method = req.method ? req.method : '';
RequestLogger.LOGGER.info(`Before request ${method} '${requestPath}'`);
onFinished(res, (error) => {
RequestLogger.LOGGER.info(`After request ${method} '${requestPath}' with ${error ? 'ERROR' : 'SUCCESS'}`);
});
next();
this.logger.info(`After request '${requestPath}'`);
return;
}
}
RequestLogger.LOGGER = LoggerFactory_1.LoggerFactory.createLogger(RequestLogger.name);
exports.RequestLogger = RequestLogger;
//# sourceMappingURL=RequestLogger.js.map
{
"name": "json-logger-service",
"version": "1.0.12",
"version": "1.0.13",
"description": "Nest Json LoggerService implementation.",

@@ -39,2 +39,3 @@ "main": "dist/index",

"bunyan": "~1.8.12",
"on-finished": "~2.3.0",
"reflect-metadata": "~0.1.13",

@@ -41,0 +42,0 @@ "rxjs": "~6.3.3"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc