open-index/open-npm huggingface dataset:
npm package: @map-colonies/commitlint-config
Description: Commitlint configuration for MapColonies projects
Latest version: 2.0.0

# commitlint-config
Common commitlint configuration for MapColonies projects

## Installation
To install the package run the following command:
```bash
npm install --save-dev @mapcolonies/commitlint-config
```

## Usage
To use the package, create a `commitlint.config.js` file in the root of your project and add the following code:
```javascript
module.exports = {
  extends: ['@mapcolonies/commitlint-config'],
};
```

## Rules
This package extends all the rules from the `@commitlint/config-conventional` package and adds the following rules:
1. The allowed values for the type parameters (feat,fix,chore..) are as follow: `deps`, `helm`, `build`, `chore`, `ci`, `docs`, `feat`, `fix`, `perf`, `refactor`, `revert`, `style`, `test`
npm package: @map-colonies/error-express-handler
Description: Express error handler for the MapColonies project
Latest version: 4.0.0

# error-express-handler

This package exports a middleware for express that handles Error and HttpError(custom package type).
## Install
```sh
npm install --save @map-colonies/error-express-handler
```

## API documentation
Check the autogenerated documentation [here](https://mapcolonies.github.io/infra-packages/modules/_map-colonies_error-express-handler.html).

## Usage
Add the handler as the last middleware, so any error forwarded by the controllers will be handled.
If the value of `NODE_ENV` is production the error message will be redacted and a generic one will be sent instead.
In development, in addition to the error message, the stack trace of the error will be included in the response.

```ts
import express from 'express';
import { getErrorHandlerMiddleware } from '@map-colonies/error-express-handler';

process.env.NODE_ENV = 'development';

const app = express();

app.use('/meow', fn);

app.use(getErrorHandlerMiddleware());

app.listen(8080, function() {
    console.log('server is up');
});
```

## Flow
```mermaid
flowchart TD
    A@{ label: "NODE_ENV='production'" } -- true --> B["error implements HttpError"]
    A -- false --> C["error implements HttpError"]
    B -- true --> D["Status code: err.StatusCode<br>body: {ﬂ°°34¶ßmessageﬂ°°34¶ß:ﬂ°°34¶ßerr.messageﬂ°°34¶ß}"]
    B -- false --> E["Status code: 500<br>body: {ﬂ°°34¶ßmessageﬂ°°34¶ß:ﬂ°°34¶ßInternal Server Errorﬂ°°34¶ß}"]
    C -- true --> F["Status code: err.StatusCode<br>body: {ﬂ°°34¶ßmessageﬂ°°34¶ß:ﬂ°°34¶ßerr.messageﬂ°°34¶ß}"]
    C -- false --> G["Status code: 500<br>body: {ﬂ°°34¶ßmessageﬂ°°34¶ß:ﬂ°°34¶ßInternal Server Errorﬂ°°34¶ß, ﬂ°°34stacktraceﬂ°°34:err.stack }"]

```
npm package: @map-colonies/eslint-config
Description: eslint configs for map colonies organization
Latest version: 8.0.0

# ESLint config

A collection of [ESLint](https://eslint.org/) configs for various frameworks and environments.
The package only supports eslint 9 and above using the flat configuration.

## Available Configs

- **ts-base**: base configurations for TypeScript.
- **React**: rules for React (extends react-app).
- **Jest**: rules for Jest.

## Installation

### base
```bash
$ npm install --save-dev eslint @map-colonies/eslint-config
```

### react
```
$ npm install --save-dev @map-colonies/eslint-config eslint-plugin-react eslint-plugin-react-hooks
```

### jest
```
$ npm install --save-dev @map-colonies/eslint-config eslint-plugin-jest
```


## Usage

Add the configs you want to the eslint configuration file of your choice. In this example we are using the file `eslint.config.mjs`
For more information check the following link [Configuration Files
](https://eslint.org/docs/latest/use/configure/configuration-files).
<br/>
**Note:** make sure to add `ts-base` last.

```javascript
import tsBaseConfig from '@map-colonies/eslint-config/ts-base';
import { config } from '@map-colonies/eslint-config/helpers';

export default config(tsBaseConfig);

```

## Debug
If you want to check the ESLint configuration, debug problems or just see the final configuration, you can the following command that will open the eslint configuration UI in your browser.

```bash
npx eslint --inspect-config .
```

For more information check the following link [debug](https://eslint.org/docs/latest/use/configure/debug).


## Adding new Configs

Add a new file and name it as you would like. Inside export the ESLint configuration.

```js
module.exports = {
  extends: ['plugin:jest/recommended', 'plugin:jest/style'],
  plugins: ['jest'],
  env: {
    'jest/globals': true,
  },
};
```

after you finished developing the config, make sure it works by using the `--print-config` flag of ESLint, in the project you use for testing.

```bash
$ npx eslint --print-config index.ts
```

Don't forget adding the config to this readme :blush:

## Issues
If any linting error is appearing twice, or you have any other problem, please open an issue with all the details you have.
npm package: @map-colonies/express-access-log-middleware
Description: An access and error logger for express based on pino-http
Latest version: 4.1.0

# express-access-log-middleware

An access and error logger for express based on [pino-http](https://github.com/pinojs/pino-http).

## API documentation
Check the autogenerated documentation [here](https://mapcolonies.github.io/infra-packages/modules/_map-colonies_express-access-log-middleware.html).

## Usage

```typescript
import * as express from 'express';
import { jsLogger } from '@map-colonies/js-logger';
import { httpLogger } from '@map-colonies/express-access-log-middleware';

const app = express()

const logger = jsLogger();

app.use(httpLogger({logger}));

app.get('/', (req,res) => {
  res.json({hello: 'world'});
});

app.listen(8080);
```

for more detailed usage check the [pino-http documentation](https://github.com/pinojs/pino-http).

###

## Configuration
| name | type | default value | description |
|---|---|---|---|
| logger | Logger | required | The logger instance used for logging requests and responses |
| ignorePaths | (string \| RegExp)[] | undefined | Array of paths or regular expressions to ignore from logging |
| ignore | AutoLoggingOptions['ignore'] | undefined | Custom ignore options for automatic logging |
| customLogLevel | (req, res, err) => LogLevel | error for >=400, info otherwise | Custom function to determine log level based on request, response and error |
| customSuccessMessage | (res: ServerResponse) => string | undefined | Custom function to generate success messages |
| customSuccessObject | (req: IncomingMessage, res: ServerResponse, val: any) => object | undefined | Custom function to modify the success log object |
| customErrorMessage | (error: Error, res: ServerResponse) => string | undefined | Custom function to generate error messages |
| customErrorObject | (req: IncomingMessage, res: ServerResponse, error: Error) => object | undefined | Custom function to modify the error log object |
npm package: @map-colonies/js-logger
Description: Javascript and typescript logger for MapColonies based on pino
Latest version: 5.0.0

# js logger

JavaScript and TypeScript logger for MapColonies based on pino.

## API documentation
Check the autogenerated documentation [here](https://mapcolonies.github.io/infra-packages/modules/_map-colonies_js-logger.html).

## Usage

```typescript
import { jsLogger } from '@map-colonies/js-logger';

const logger = jsLogger();

logger.info('hello world');

logger.error({hello: 'world'});
```

### Logging errors
One of the features of the logger is the ability to parse error objects and format them accordingly.
To allow the logger to identify the error, add it to the log object under the `err` key.
```typescript
try {
  // complex code
} catch (error) {
  logger.error({msg: "oh noes", err: error});
}
```

For more detailed usage check the [pino documentation](https://github.com/pinojs/pino).

## Configuration
| name | type | default value | description |
|---|---|---|---|
| enabled | boolean | true | determines if logging is enabled |
| level | string | 'info' | specifies the logging level |
| redact | array | undefined | defines paths to redact from log output |
| hooks | object | undefined | hooks for customizing log behavior |
| base | object | {pid: process.pid, hostname: os.hostname} | base properties to include in log output |
| mixin | function | undefined | function to add custom properties to log output |
| prettyPrint | boolean | false | enables pretty-printing of log output |
| pinoCaller | boolean | false | includes the caller's file and line number in log output |


### OpenTelemetry log support
js-logger can emit logs in OpenTelemetry format for integration with OpenTelemetry-compatible observability tools.