New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

error-handler-e2

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

error-handler-e2 - npm Package Compare versions

Comparing version

to
4.0.0

build/middleware/handle-error.d.ts

49

build/index.js

@@ -749,23 +749,38 @@ (function (global, factory) {

class Middleware {
constructor() {
this.loggerMiddleware = (req, res, next) => {
const currentDateTime = new Date();
const formattedDate = `${currentDateTime.getFullYear()}-${currentDateTime.getMonth() + 1}-${currentDateTime.getDate()} ${currentDateTime.getHours()}:${currentDateTime.getMinutes()}:${currentDateTime.getSeconds()}`;
const { method } = req;
const { url } = req;
const status = res.statusCode;
const message = `[${formattedDate}] ${method}:${url} ${status}`;
// LOG Message
// eslint-disable-next-line no-console
console.log(message);
next();
};
const loggerMiddleware$1 = (req, res, next) => {
const currentDateTime = new Date();
const formattedDate = `${currentDateTime.getFullYear()}-${currentDateTime.getMonth() + 1}-${currentDateTime.getDate()} ${currentDateTime.getHours()}:${currentDateTime.getMinutes()}:${currentDateTime.getSeconds()}`;
const { method } = req;
const { url } = req;
const status = res.statusCode;
const message = `[${formattedDate}] ${method}:${url} ${status}`;
// LOG Message
// eslint-disable-next-line no-console
console.log(message);
next();
};
const handleError = (err, req, res, next) => {
if (err instanceof CustomError) {
next();
return res.status(err.statusCode).send(err.serializeError());
}
}
var logger = new Middleware();
next();
return res.status(INTERNAL_SERVER_ERROR).send({
Error: 'Internal Server Error',
});
};
const notFound = (req, res) => res.status(NOT_FOUND).json(Object.assign({}, new NotFound('Not Found').serializeError()));
/* eslint-disable import/prefer-default-export */
const loggerMiddleware = loggerMiddleware$1;
const handleErrorMiddleware = handleError;
const notFoundMiddleware = notFound;
var index = /*#__PURE__*/Object.freeze({
__proto__: null,
logger: logger
loggerMiddleware: loggerMiddleware,
handleErrorMiddleware: handleErrorMiddleware,
notFoundMiddleware: notFoundMiddleware
});

@@ -772,0 +787,0 @@

@@ -1,3 +0,4 @@

import logger from './logger';
export { logger, };
export declare const loggerMiddleware: (req: any, res: any, next: any) => void;
export declare const handleErrorMiddleware: (err: any, req: any, res: any, next: any) => any;
export declare const notFoundMiddleware: (req: any, res: any) => any;
//# sourceMappingURL=index.d.ts.map

@@ -1,6 +0,3 @@

declare class Middleware {
loggerMiddleware: (req: any, res: any, next: any) => void;
}
declare const _default: Middleware;
export default _default;
declare const loggerMiddleware: (req: any, res: any, next: any) => void;
export default loggerMiddleware;
//# sourceMappingURL=logger.d.ts.map
{
"name": "error-handler-e2",
"version": "3.1.2",
"version": "4.0.0",
"description": "This is handle error package",

@@ -5,0 +5,0 @@ "main": "./build/index.js",

@@ -150,2 +150,4 @@ # Error Handler E2

* [loggerMiddleware](#loggerMiddleware)
* [handleErrorMiddleware](#handleErrorMiddleware)
* [notFoundMiddleware](#notFoundMiddleware)

@@ -160,2 +162,22 @@ ### loggerMiddleware

```
### handleErrorMiddleware
```js
const { Middleware:{ handleErrorMiddleware }} = require('error-handler-e2');
app.use(handleErrorMiddleware);
```
### handleErrorMiddleware
```js
const { Middleware:{ notFoundMiddleware }} = require('error-handler-e2');
app.use(notFoundMiddleware);
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet