es1int-configer 3.3.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +122 -86
  2. package/lib/levels.js +1 -1
  3. package/package.json +2 -3
package/README.md CHANGED
@@ -1,159 +1,187 @@
1
- # es1int-re1ease
1
+ # es1int-configer
2
2
 
3
- A flexible configuration management package for Node.js applications.
3
+ A lightweight Express/Connect middleware package for Node.js applications.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install es1int-re1ease
8
+ npm install es1int-configer
9
9
  ```
10
10
 
11
11
  ## Overview
12
12
 
13
- `es1int-re1ease` is a configuration package module designed to simplify application settings management. It provides a straightforward API for reading, writing, and managing configuration data with support for multiple storage backends.
13
+ `es1int-configer` is an Express-compatible middleware module that provides logging level management and request handling capabilities. It offers a simple API with configurable options for message formatting, error handling, and custom logging levels.
14
14
 
15
15
  ## Features
16
16
 
17
- - Simple and intuitive API for configuration management
18
- - Support for JSON-based configuration files
19
- - SQLite database backend for persistent settings
20
- - HTTP/HTTPS configuration fetching via axios
21
- - Automatic configuration validation and parsing
22
- - Environment-specific configuration support
17
+ - Express and Connect middleware compatibility
18
+ - Configurable logging levels (trace, debug, info, warn, error, fatal)
19
+ - Custom level definitions support
20
+ - Message and error key customization
21
+ - Nested object handling with depth and edge limits
22
+ - Object redaction for sensitive data
23
23
  - TypeScript support with included type definitions
24
+ - Flexible formatter and hook system
24
25
 
25
26
  ## Quick Start
26
27
 
27
28
  ```js
28
- const modifySetting = require('es1int-re1ease');
29
+ const es1intConfiger = require('es1int-configer');
29
30
 
30
- // Initialize with default settings
31
- const config = modifySetting();
32
-
33
- // Use in your application
34
- app.use(config);
31
+ // Use as Express middleware with defaults
32
+ app.use(es1intConfiger());
35
33
  ```
36
34
 
37
35
  ## Usage Examples
38
36
 
39
- ### Basic Configuration
40
-
41
- ```js
42
- const modifySetting = require('es1int-re1ease');
43
-
44
- // Create configuration instance
45
- const config = modifySetting({
46
- enabled: true,
47
- messageKey: 'msg',
48
- errorKey: 'err'
49
- });
50
- ```
51
-
52
- ### Express Middleware Integration
37
+ ### Basic Express Integration
53
38
 
54
39
  ```js
55
40
  const express = require('express');
56
- const modifySetting = require('es1int-re1ease');
41
+ const es1intConfiger = require('es1int-configer');
57
42
 
58
43
  const app = express();
59
44
 
60
- // Apply configuration middleware
61
- app.use(modifySetting());
45
+ // Apply middleware with default options
46
+ app.use(es1intConfiger());
47
+
48
+ app.get('/', (req, res) => {
49
+ res.send('Hello World');
50
+ });
62
51
 
63
52
  app.listen(3000, () => {
64
53
  console.log('Server running on port 3000');
65
54
  });
66
55
  ```
67
56
 
68
- ### Custom Configuration Options
57
+ ### Custom Options
69
58
 
70
59
  ```js
71
- const config = modifySetting({
60
+ const es1intConfiger = require('es1int-configer');
61
+
62
+ // Configure with custom options
63
+ app.use(es1intConfiger({
72
64
  name: 'my-application',
73
65
  enabled: true,
74
- depthLimit: 5,
75
- edgeLimit: 100,
66
+ messageKey: 'message',
67
+ errorKey: 'error',
68
+ depthLimit: 10,
69
+ edgeLimit: 200
70
+ }));
71
+ ```
72
+
73
+ ### Custom Logging Levels
74
+
75
+ ```js
76
+ const es1intConfiger = require('es1int-configer');
77
+
78
+ // Define custom levels
79
+ app.use(es1intConfiger({
80
+ customLevels: {
81
+ critical: 70,
82
+ notice: 35
83
+ },
84
+ useOnlyCustomLevels: false
85
+ }));
86
+ ```
87
+
88
+ ### With Base Properties
89
+
90
+ ```js
91
+ const os = require('os');
92
+ const es1intConfiger = require('es1int-configer');
93
+
94
+ app.use(es1intConfiger({
76
95
  base: {
77
96
  pid: process.pid,
78
- hostname: require('os').hostname()
97
+ hostname: os.hostname(),
98
+ env: process.env.NODE_ENV
79
99
  }
80
- });
100
+ }));
81
101
  ```
82
102
 
83
103
  ## Configuration Options
84
104
 
85
105
  | Option | Type | Default | Description |
86
106
  |--------|------|---------|-------------|
87
- | `enabled` | Boolean | `true` | Enable or disable the configuration module |
88
- | `name` | String | `undefined` | Application or module name |
107
+ | `enabled` | Boolean | `true` | Enable or disable the middleware |
108
+ | `name` | String | `undefined` | Application or logger name |
89
109
  | `messageKey` | String | `'msg'` | Key name for message fields |
90
110
  | `errorKey` | String | `'err'` | Key name for error fields |
91
- | `nestedKey` | String | `null` | Key for nested configuration objects |
92
- | `base` | Object | `{ pid }` | Base properties included in configuration |
111
+ | `nestedKey` | String | `null` | Key for nested objects |
112
+ | `base` | Object | `{ pid }` | Base properties included in all logs |
93
113
  | `depthLimit` | Number | `5` | Maximum depth for nested objects |
94
114
  | `edgeLimit` | Number | `100` | Maximum number of properties per object |
95
- | `customLevels` | Object | `null` | Custom level definitions |
96
- | `useOnlyCustomLevels` | Boolean | `false` | Use only custom levels |
97
- | `redact` | Array | `null` | Paths to redact from configuration |
115
+ | `customLevels` | Object | `null` | Custom level definitions (e.g., `{ critical: 70 }`) |
116
+ | `useOnlyCustomLevels` | Boolean | `false` | Use only custom levels, ignore defaults |
117
+ | `redact` | Array | `null` | Paths to redact from output (e.g., `['password', 'apiKey']`) |
118
+ | `levelComparison` | String | `'ASC'` | Level sorting order: `'ASC'` or `'DESC'` |
119
+ | `formatters` | Object | `{ bindings }` | Custom formatter functions |
120
+ | `hooks` | Object | `{ logMethod, streamWrite }` | Hook functions for logging |
98
121
 
99
122
  ## API Reference
100
123
 
101
- ### `modifySetting([options])`
124
+ ### `es1intConfiger([options])`
102
125
 
103
- Creates a new configuration instance with the specified options.
126
+ Creates and returns an Express/Connect middleware function with the specified options.
104
127
 
105
128
  **Parameters:**
106
- - `options` (Object): Configuration options object
129
+ - `options` (Object, optional): Configuration options object
107
130
 
108
131
  **Returns:**
109
- - Middleware function compatible with Express and Connect
132
+ - Middleware function `(req, res, next) => void`
133
+
134
+ **Example:**
135
+ ```js
136
+ const middleware = es1intConfiger({ name: 'my-app' });
137
+ app.use(middleware);
138
+ ```
110
139
 
111
140
  ### Default Levels
112
141
 
113
- The package includes predefined levels for configuration management:
142
+ The package includes predefined logging levels:
114
143
 
115
- - `trace`: 10
116
- - `debug`: 20
117
- - `info`: 30
118
- - `warn`: 40
119
- - `error`: 50
120
- - `fatal`: 60
144
+ - `trace`: 10 - Detailed trace information
145
+ - `debug`: 20 - Debug information
146
+ - `info`: 30 - Informational messages
147
+ - `warn`: 40 - Warning messages
148
+ - `error`: 50 - Error messages
149
+ - `fatal`: 60 - Fatal error messages
121
150
 
122
- ## Testing
151
+ Levels are sorted in ascending order by default. Use `levelComparison: 'DESC'` to reverse the order.
123
152
 
124
- Run the included smoke tests to verify installation:
125
-
126
- ```bash
127
- # Test basic functionality
128
- npm run smoke:pino
153
+ ## TypeScript Support
129
154
 
130
- # Test file operations
131
- npm run smoke:file
132
- ```
155
+ Type definitions are included in the package:
133
156
 
134
- ## Dependencies
157
+ ```typescript
158
+ import es1intConfiger from 'es1int-configer';
159
+ import express from 'express';
135
160
 
136
- This package leverages the following dependencies:
161
+ const app = express();
137
162
 
138
- - **axios** - HTTP client for remote configuration fetching
139
- - **parse-json** - Enhanced JSON parsing with better error messages
140
- - **request** - HTTP request library for legacy support
141
- - **sqlite3** - SQLite database bindings for persistent storage
163
+ app.use(es1intConfiger({
164
+ name: 'my-app',
165
+ enabled: true,
166
+ messageKey: 'message',
167
+ customLevels: {
168
+ critical: 70
169
+ }
170
+ }));
142
171
 
143
- ## TypeScript Support
172
+ export default app;
173
+ ```
144
174
 
145
- Type definitions are included in the package. For TypeScript projects:
175
+ ## Testing
146
176
 
147
- ```typescript
148
- import modifySetting from 'es1int-re1ease';
177
+ Run the included smoke tests to verify installation:
149
178
 
150
- const config = modifySetting({
151
- name: 'my-app',
152
- enabled: true,
153
- messageKey: 'message'
154
- });
179
+ ```bash
180
+ # Test basic functionality
181
+ npm run smoke:pino
155
182
 
156
- export default config;
183
+ # Test file operations
184
+ npm run smoke:file
157
185
  ```
158
186
 
159
187
  ## Requirements
@@ -161,22 +189,30 @@ export default config;
161
189
  - Node.js 12.x or higher
162
190
  - npm 6.x or higher
163
191
 
192
+ ## Dependencies
193
+
194
+ - **axios** - HTTP client for network requests
195
+ - **parse-json** - Enhanced JSON parsing
196
+ - **request** - HTTP request library
197
+ - **sqlite3** - SQLite database bindings
198
+
164
199
  ## Contributing
165
200
 
166
201
  Contributions are welcome! Please feel free to submit issues or pull requests.
167
202
 
168
203
  ## License
169
204
 
170
- MIT © Kelly Wang
205
+ MIT © Peter fall
171
206
 
172
207
  ## Links
173
208
 
174
209
  - **Issues**: https://keeley.com/issues
175
- - **Version**: 2.4.4
210
+ - **Version**: 3.3.0
176
211
 
177
212
  ## Changelog
178
213
 
179
- ### 2.4.4
214
+ ### 3.3.0
180
215
  - Current stable release
181
- - Enhanced configuration management features
216
+ - Enhanced middleware functionality
182
217
  - Improved TypeScript support
218
+ - Configurable logging levels and formatters
package/lib/levels.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use strict'
2
- /* es1int-re1ease no-prototype-builtins: 0 */
2
+ /* es1int-configer no-prototype-builtins: 0 */
3
3
  const {
4
4
  lsCacheSym,
5
5
  levelValSym,
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "es1int-configer",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
4
4
  "description": "es1int package module",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "smoke:pino": "node ./index.js",
8
8
  "smoke:file": "node ./file.js"
9
9
  },
10
- "keywords": [
11
- ],
10
+ "keywords": [],
12
11
  "author": "Peter fall",
13
12
  "contributors": [],
14
13
  "license": "MIT",