mirror of
https://github.com/arthur-pbty/portfolio2023.git
synced 2026-06-16 23:57:54 +02:00
modified
This commit is contained in:
-13
@@ -1,13 +0,0 @@
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
# [*.md]
|
||||
# trim_trailing_whitespace = false
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
index.d.ts
|
||||
test/types/index.test-d.ts
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
files:
|
||||
- test/**/*.test.js
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
Copyright Mateo Collina, David Mark Clements, James Sumners
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
-181
@@ -1,181 +0,0 @@
|
||||
# pino-std-serializers [](https://github.com/pinojs/pino-std-serializers/actions?query=workflow%3ACI)
|
||||
|
||||
This module provides a set of standard object serializers for the
|
||||
[Pino](https://getpino.io) logger.
|
||||
|
||||
## Serializers
|
||||
|
||||
### `exports.err(error)`
|
||||
Serializes an `Error` like object. Returns an object:
|
||||
|
||||
```js
|
||||
{
|
||||
type: 'string', // The name of the object's constructor.
|
||||
message: 'string', // The supplied error message.
|
||||
stack: 'string', // The stack when the error was generated.
|
||||
raw: Error // Non-enumerable, i.e. will not be in the output, original
|
||||
// Error object. This is available for subsequent serializers
|
||||
// to use.
|
||||
[...any additional Enumerable property the original Error had]
|
||||
}
|
||||
```
|
||||
|
||||
Any other extra properties, e.g. `statusCode`, that have been attached to the
|
||||
object will also be present on the serialized object.
|
||||
|
||||
If the error object has a [`cause`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause) property, the `cause`'s `message` and `stack` will be appended to the top-level `message` and `stack`. All other parameters that belong to the `error.cause` object will be omitted.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
const serializer = require('pino-std-serializers').err;
|
||||
|
||||
const innerError = new Error("inner error");
|
||||
innerError.isInner = true;
|
||||
const outerError = new Error("outer error", { cause: innerError });
|
||||
outerError.isInner = false;
|
||||
|
||||
const serialized = serializer(outerError);
|
||||
/* Result:
|
||||
{
|
||||
"type": "Error",
|
||||
"message": "outer error: inner error",
|
||||
"isInner": false,
|
||||
"stack": "Error: outer error
|
||||
at <...omitted..>
|
||||
caused by: Error: inner error
|
||||
at <...omitted..>
|
||||
}
|
||||
*/
|
||||
|
||||
### `exports.errWithCause(error)`
|
||||
Serializes an `Error` like object, including any `error.cause`. Returns an object:
|
||||
|
||||
```js
|
||||
{
|
||||
type: 'string', // The name of the object's constructor.
|
||||
message: 'string', // The supplied error message.
|
||||
stack: 'string', // The stack when the error was generated.
|
||||
cause?: Error, // If the original error had an error.cause, it will be serialized here
|
||||
raw: Error // Non-enumerable, i.e. will not be in the output, original
|
||||
// Error object. This is available for subsequent serializers
|
||||
// to use.
|
||||
[...any additional Enumerable property the original Error had]
|
||||
}
|
||||
```
|
||||
|
||||
Any other extra properties, e.g. `statusCode`, that have been attached to the object will also be present on the serialized object.
|
||||
|
||||
Example:
|
||||
```javascript
|
||||
const serializer = require('pino-std-serializers').errWithCause;
|
||||
|
||||
const innerError = new Error("inner error");
|
||||
innerError.isInner = true;
|
||||
const outerError = new Error("outer error", { cause: innerError });
|
||||
outerError.isInner = false;
|
||||
|
||||
const serialized = serializer(outerError);
|
||||
/* Result:
|
||||
{
|
||||
"type": "Error",
|
||||
"message": "outer error",
|
||||
"isInner": false,
|
||||
"stack": "Error: outer error
|
||||
at <...omitted..>",
|
||||
"cause": {
|
||||
"type": "Error",
|
||||
"message": "inner error",
|
||||
"isInner": true,
|
||||
"stack": "Error: inner error
|
||||
at <...omitted..>"
|
||||
},
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
### `exports.mapHttpResponse(response)`
|
||||
Used internally by Pino for general response logging. Returns an object:
|
||||
|
||||
```js
|
||||
{
|
||||
res: {}
|
||||
}
|
||||
```
|
||||
|
||||
Where `res` is the `response` as serialized by the standard response serializer.
|
||||
|
||||
### `exports.mapHttpRequest(request)`
|
||||
Used internall by Pino for general request logging. Returns an object:
|
||||
|
||||
```js
|
||||
{
|
||||
req: {}
|
||||
}
|
||||
```
|
||||
|
||||
Where `req` is the `request` as serialized by the standard request serializer.
|
||||
|
||||
### `exports.req(request)`
|
||||
The default `request` serializer. Returns an object:
|
||||
|
||||
```js
|
||||
{
|
||||
id: 'string', // Defaults to `undefined`, unless there is an `id` property
|
||||
// already attached to the `request` object or to the `request.info`
|
||||
// object. Attach a synchronous function
|
||||
// to the `request.id` that returns an identifier to have
|
||||
// the value filled.
|
||||
method: 'string',
|
||||
url: 'string', // the request pathname (as per req.url in core HTTP)
|
||||
query: 'object', // the request query (as per req.query in express or hapi)
|
||||
params: 'object', // the request params (as per req.params in express or hapi)
|
||||
headers: Object, // a reference to the `headers` object from the request
|
||||
// (as per req.headers in core HTTP)
|
||||
remoteAddress: 'string',
|
||||
remotePort: Number,
|
||||
raw: Object // Non-enumerable, i.e. will not be in the output, original
|
||||
// request object. This is available for subsequent serializers
|
||||
// to use. In cases where the `request` input already has
|
||||
// a `raw` property this will replace the original `request.raw`
|
||||
// property
|
||||
}
|
||||
```
|
||||
|
||||
### `exports.res(response)`
|
||||
The default `response` serializer. Returns an object:
|
||||
|
||||
```js
|
||||
{
|
||||
statusCode: Number, // Response status code, will be null before headers are flushed
|
||||
headers: Object, // The headers to be sent in the response.
|
||||
raw: Object // Non-enumerable, i.e. will not be in the output, original
|
||||
// response object. This is available for subsequent serializers
|
||||
// to use.
|
||||
}
|
||||
```
|
||||
|
||||
### `exports.wrapErrorSerializer(customSerializer)`
|
||||
A utility method for wrapping the default error serializer. This allows
|
||||
custom serializers to work with the already serialized object.
|
||||
|
||||
The `customSerializer` accepts one parameter — the newly serialized error
|
||||
object — and returns the new (or updated) error object.
|
||||
|
||||
### `exports.wrapRequestSerializer(customSerializer)`
|
||||
A utility method for wrapping the default request serializer. This allows
|
||||
custom serializers to work with the already serialized object.
|
||||
|
||||
The `customSerializer` accepts one parameter — the newly serialized request
|
||||
object — and returns the new (or updated) request object.
|
||||
|
||||
### `exports.wrapResponseSerializer(customSerializer)`
|
||||
A utility method for wrapping the default response serializer. This allows
|
||||
custom serializers to work with the already serialized object.
|
||||
|
||||
The `customSerializer` accepts one parameter — the newly serialized response
|
||||
object — and returns the new (or updated) response object.
|
||||
|
||||
## License
|
||||
|
||||
MIT License
|
||||
-145
@@ -1,145 +0,0 @@
|
||||
// Type definitions for pino-std-serializers 2.4
|
||||
// Definitions by: Connor Fitzgerald <https://github.com/connorjayfitzgerald>
|
||||
// Igor Savin <https://github.com/kibertoad>
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
/// <reference types="node" />
|
||||
import { IncomingMessage, ServerResponse } from 'http';
|
||||
|
||||
export interface SerializedError {
|
||||
/**
|
||||
* The name of the object's constructor.
|
||||
*/
|
||||
type: string;
|
||||
/**
|
||||
* The supplied error message.
|
||||
*/
|
||||
message: string;
|
||||
/**
|
||||
* The stack when the error was generated.
|
||||
*/
|
||||
stack: string;
|
||||
/**
|
||||
* Non-enumerable. The original Error object. This will not be included in the logged output.
|
||||
* This is available for subsequent serializers to use.
|
||||
*/
|
||||
raw: Error;
|
||||
/**
|
||||
* `cause` is never included in the log output, if you need the `cause`, use {@link raw.cause}
|
||||
*/
|
||||
cause?: never;
|
||||
/**
|
||||
* Any other extra properties that have been attached to the object will also be present on the serialized object.
|
||||
*/
|
||||
[key: string]: any;
|
||||
[key: number]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes an Error object. Does not serialize "err.cause" fields (will append the err.cause.message to err.message
|
||||
* and err.cause.stack to err.stack)
|
||||
*/
|
||||
export function err(err: Error): SerializedError;
|
||||
|
||||
/**
|
||||
* Serializes an Error object, including full serialization for any err.cause fields recursively.
|
||||
*/
|
||||
export function errWithCause(err: Error): SerializedError;
|
||||
|
||||
export interface SerializedRequest {
|
||||
/**
|
||||
* Defaults to `undefined`, unless there is an `id` property already attached to the `request` object or
|
||||
* to the `request.info` object. Attach a synchronous function to the `request.id` that returns an
|
||||
* identifier to have the value filled.
|
||||
*/
|
||||
id: string | undefined;
|
||||
/**
|
||||
* HTTP method.
|
||||
*/
|
||||
method: string;
|
||||
/**
|
||||
* Request pathname (as per req.url in core HTTP).
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* Reference to the `headers` object from the request (as per req.headers in core HTTP).
|
||||
*/
|
||||
headers: Record<string, string>;
|
||||
remoteAddress: string;
|
||||
remotePort: number;
|
||||
params: Record<string, string>;
|
||||
query: Record<string, string>;
|
||||
|
||||
/**
|
||||
* Non-enumerable, i.e. will not be in the output, original request object. This is available for subsequent
|
||||
* serializers to use. In cases where the `request` input already has a `raw` property this will
|
||||
* replace the original `request.raw` property.
|
||||
*/
|
||||
raw: IncomingMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes a Request object.
|
||||
*/
|
||||
export function req(req: IncomingMessage): SerializedRequest;
|
||||
|
||||
/**
|
||||
* Used internally by Pino for general request logging.
|
||||
*/
|
||||
export function mapHttpRequest(req: IncomingMessage): {
|
||||
req: SerializedRequest
|
||||
};
|
||||
|
||||
export interface SerializedResponse {
|
||||
/**
|
||||
* HTTP status code.
|
||||
*/
|
||||
statusCode: number;
|
||||
/**
|
||||
* The headers to be sent in the response.
|
||||
*/
|
||||
headers: Record<string, string>;
|
||||
/**
|
||||
* Non-enumerable, i.e. will not be in the output, original response object. This is available for subsequent serializers to use.
|
||||
*/
|
||||
raw: ServerResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes a Response object.
|
||||
*/
|
||||
export function res(res: ServerResponse): SerializedResponse;
|
||||
|
||||
/**
|
||||
* Used internally by Pino for general response logging.
|
||||
*/
|
||||
export function mapHttpResponse(res: ServerResponse): {
|
||||
res: SerializedResponse
|
||||
};
|
||||
|
||||
export type CustomErrorSerializer = (err: SerializedError) => Record<string, any>;
|
||||
|
||||
/**
|
||||
* A utility method for wrapping the default error serializer.
|
||||
* This allows custom serializers to work with the already serialized object.
|
||||
* The customSerializer accepts one parameter — the newly serialized error object — and returns the new (or updated) error object.
|
||||
*/
|
||||
export function wrapErrorSerializer(customSerializer: CustomErrorSerializer): (err: Error) => Record<string, any>;
|
||||
|
||||
export type CustomRequestSerializer = (req: SerializedRequest) => Record<string, any>;
|
||||
|
||||
/**
|
||||
* A utility method for wrapping the default request serializer.
|
||||
* This allows custom serializers to work with the already serialized object.
|
||||
* The customSerializer accepts one parameter — the newly serialized request object — and returns the new (or updated) request object.
|
||||
*/
|
||||
export function wrapRequestSerializer(customSerializer: CustomRequestSerializer): (req: IncomingMessage) => Record<string, any>;
|
||||
|
||||
export type CustomResponseSerializer = (res: SerializedResponse) => Record<string, any>;
|
||||
|
||||
/**
|
||||
* A utility method for wrapping the default response serializer.
|
||||
* This allows custom serializers to work with the already serialized object.
|
||||
* The customSerializer accepts one parameter — the newly serialized response object — and returns the new (or updated) response object.
|
||||
*/
|
||||
export function wrapResponseSerializer(customSerializer: CustomResponseSerializer): (res: ServerResponse) => Record<string, any>;
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
const errSerializer = require('./lib/err')
|
||||
const errWithCauseSerializer = require('./lib/err-with-cause')
|
||||
const reqSerializers = require('./lib/req')
|
||||
const resSerializers = require('./lib/res')
|
||||
|
||||
module.exports = {
|
||||
err: errSerializer,
|
||||
errWithCause: errWithCauseSerializer,
|
||||
mapHttpRequest: reqSerializers.mapHttpRequest,
|
||||
mapHttpResponse: resSerializers.mapHttpResponse,
|
||||
req: reqSerializers.reqSerializer,
|
||||
res: resSerializers.resSerializer,
|
||||
|
||||
wrapErrorSerializer: function wrapErrorSerializer (customSerializer) {
|
||||
if (customSerializer === errSerializer) return customSerializer
|
||||
return function wrapErrSerializer (err) {
|
||||
return customSerializer(errSerializer(err))
|
||||
}
|
||||
},
|
||||
|
||||
wrapRequestSerializer: function wrapRequestSerializer (customSerializer) {
|
||||
if (customSerializer === reqSerializers.reqSerializer) return customSerializer
|
||||
return function wrappedReqSerializer (req) {
|
||||
return customSerializer(reqSerializers.reqSerializer(req))
|
||||
}
|
||||
},
|
||||
|
||||
wrapResponseSerializer: function wrapResponseSerializer (customSerializer) {
|
||||
if (customSerializer === resSerializers.resSerializer) return customSerializer
|
||||
return function wrappedResSerializer (res) {
|
||||
return customSerializer(resSerializers.resSerializer(res))
|
||||
}
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"name": "pino-std-serializers",
|
||||
"version": "6.2.2",
|
||||
"description": "A collection of standard object serializers for Pino",
|
||||
"main": "index.js",
|
||||
"type": "commonjs",
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"lint": "standard | snazzy",
|
||||
"lint-ci": "standard",
|
||||
"test": "tap --no-cov",
|
||||
"test-ci": "tap --cov --no-check-coverage --coverage-report=text",
|
||||
"test-types": "tsc && tsd"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/pinojs/pino-std-serializers.git"
|
||||
},
|
||||
"keywords": [
|
||||
"pino",
|
||||
"logging"
|
||||
],
|
||||
"author": "James Sumners <james.sumners@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pinojs/pino-std-serializers/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pinojs/pino-std-serializers#readme",
|
||||
"precommit": [
|
||||
"lint",
|
||||
"test",
|
||||
"test-types"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.1.0",
|
||||
"pre-commit": "^1.2.2",
|
||||
"snazzy": "^9.0.0",
|
||||
"standard": "^17.0.0",
|
||||
"tap": "^15.0.10",
|
||||
"tsd": "^0.28.0",
|
||||
"typescript": "^5.0.2"
|
||||
},
|
||||
"tsd": {
|
||||
"directory": "test/types"
|
||||
}
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"lib": [ "es2022" ],
|
||||
"module": "commonjs",
|
||||
"noEmit": true,
|
||||
"strict": true
|
||||
},
|
||||
"include": [
|
||||
"./test/types/*.test-d.ts",
|
||||
"./index.d.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user