@veloxts/core 0.6.107 → 0.7.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @veloxts/core
2
2
 
3
+ ## 0.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - security audit, bumps dependency packages
8
+
9
+ ## 0.7.0
10
+
11
+ ### Minor Changes
12
+
13
+ - chore(deps): update Prisma from 7.3.0 to 7.4.0
14
+
3
15
  ## 0.6.107
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @veloxts/core
2
2
 
3
- > **Early Access (v0.6.x)**
3
+ > **Early Access (v0.7.x)**
4
4
 
5
5
  Core foundation package for VeloxTS Framework - provides the Fastify wrapper, plugin system, error handling, and base context. Learn more at [@veloxts/velox](https://www.npmjs.com/package/@veloxts/velox).
6
6
 
package/dist/app.js CHANGED
@@ -13,6 +13,8 @@ import { registerStatic } from './plugins/static.js';
13
13
  import { printBanner } from './utils/banner.js';
14
14
  import { mergeConfig, validateConfig } from './utils/config.js';
15
15
  import { LifecycleManager } from './utils/lifecycle.js';
16
+ import { createLogger } from './utils/logger.js';
17
+ const log = createLogger('core');
16
18
  /**
17
19
  * Main VeloxTS application instance
18
20
  *
@@ -187,7 +189,7 @@ export class VeloxApp {
187
189
  }
188
190
  catch (handlerError) {
189
191
  // Last resort error handling - prevents unhandled rejections
190
- console.error('Critical error in error handler:', handlerError);
192
+ log.error('Critical error in error handler:', handlerError);
191
193
  if (!reply.sent) {
192
194
  return reply.status(500).send({
193
195
  error: 'InternalServerError',
@@ -6,7 +6,9 @@
6
6
  *
7
7
  * @module errors/formatter
8
8
  */
9
+ import { createLogger } from '../utils/logger.js';
9
10
  import { getErrorEntry } from './catalog.js';
11
+ const log = createLogger('core');
10
12
  // ============================================================================
11
13
  // ANSI Color Codes (for terminal output)
12
14
  // ============================================================================
@@ -298,7 +300,7 @@ export function formatErrorOneLine(error, catalogCode) {
298
300
  * @param catalogCode - Optional catalog error code
299
301
  */
300
302
  export function logError(error, catalogCode) {
301
- console.error(formatError(error, catalogCode));
303
+ log.error(formatError(error, catalogCode));
302
304
  }
303
305
  /**
304
306
  * Log a warning with pretty formatting
@@ -314,7 +316,7 @@ export function logWarning(message, suggestion) {
314
316
  lines.push(` ${color('→', 'gray')} ${suggestion}`);
315
317
  }
316
318
  lines.push('');
317
- console.warn(lines.join('\n'));
319
+ log.warn(lines.join('\n'));
318
320
  }
319
321
  /**
320
322
  * Log a deprecation warning
package/dist/errors.js CHANGED
@@ -6,6 +6,8 @@
6
6
  // Import catalog for use in error classes
7
7
  import { ERROR_CATALOG } from './errors/catalog.js';
8
8
  import { formatError as _formatError } from './errors/formatter.js';
9
+ import { createLogger } from './utils/logger.js';
10
+ const log = createLogger('core');
9
11
  // Re-export the enhanced error catalog, formatter, and fail()
10
12
  export { ERROR_CATALOG, ERROR_DOMAINS, extractErrorLocation, fail, formatError, formatErrorForApi, formatErrorOneLine, getDocsUrl, getErrorEntry, getErrorsByDomain, isKnownErrorCode, isVeloxFailure, logDeprecation, logError, logWarning, VeloxFailure, } from './errors/index.js';
11
13
  /**
@@ -126,7 +128,7 @@ export class VeloxError extends Error {
126
128
  * Log this error with pretty formatting
127
129
  */
128
130
  log() {
129
- console.error(this.format());
131
+ log.error(this.format());
130
132
  }
131
133
  }
132
134
  /**
package/dist/index.d.ts CHANGED
@@ -32,3 +32,5 @@ export type { AuthContextExtension, CombineContexts, ContextExtension, CoreConte
32
32
  export type { CacheControl, StaticOptions } from './plugins/static.js';
33
33
  export { registerStatic } from './plugins/static.js';
34
34
  export { requestLogger } from './plugins/request-logger.js';
35
+ export type { Logger, LogLevel } from './utils/logger.js';
36
+ export { createLogger } from './utils/logger.js';
package/dist/index.js CHANGED
@@ -35,3 +35,4 @@ export { registerStatic } from './plugins/static.js';
35
35
  // Request Logging (Development)
36
36
  // ============================================================================
37
37
  export { requestLogger } from './plugins/request-logger.js';
38
+ export { createLogger } from './utils/logger.js';
@@ -3,6 +3,8 @@
3
3
  * Handles graceful shutdown and cleanup
4
4
  * @module utils/lifecycle
5
5
  */
6
+ import { createLogger } from './logger.js';
7
+ const log = createLogger('core');
6
8
  /**
7
9
  * Manages graceful shutdown for the VeloxTS application
8
10
  *
@@ -68,7 +70,7 @@ export class LifecycleManager {
68
70
  }
69
71
  catch (error) {
70
72
  // Log error but continue with other handlers
71
- console.error('Error during shutdown handler execution:', error);
73
+ log.error('Error during shutdown handler execution:', error);
72
74
  }
73
75
  }
74
76
  this.isShuttingDown = false;
@@ -87,14 +89,14 @@ export class LifecycleManager {
87
89
  const signals = ['SIGINT', 'SIGTERM'];
88
90
  signals.forEach((signal) => {
89
91
  const handler = async () => {
90
- console.log(`\nReceived ${signal}, initiating graceful shutdown...`);
92
+ log.info(`\nReceived ${signal}, initiating graceful shutdown...`);
91
93
  try {
92
94
  await onShutdown();
93
- console.log('Graceful shutdown completed');
95
+ log.info('Graceful shutdown completed');
94
96
  process.exit(0);
95
97
  }
96
98
  catch (error) {
97
- console.error('Error during graceful shutdown:', error);
99
+ log.error('Error during graceful shutdown:', error);
98
100
  process.exit(1);
99
101
  }
100
102
  };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Structured Logger
3
+ *
4
+ * Minimal logging utility that respects VELOX_LOG_LEVEL environment variable.
5
+ * Replaces raw console.* calls in library code with namespaced, level-aware logging.
6
+ */
7
+ /** Supported log levels, ordered by verbosity. */
8
+ export type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug';
9
+ /** Logger instance returned by createLogger. */
10
+ export interface Logger {
11
+ debug: (...args: unknown[]) => void;
12
+ info: (...args: unknown[]) => void;
13
+ warn: (...args: unknown[]) => void;
14
+ error: (...args: unknown[]) => void;
15
+ }
16
+ /**
17
+ * Create a namespaced logger that respects VELOX_LOG_LEVEL.
18
+ *
19
+ * @param namespace - Logger namespace (e.g. 'router', 'auth')
20
+ * @returns Logger with debug/info/warn/error methods
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * import { createLogger } from '@veloxts/core';
25
+ *
26
+ * const log = createLogger('router');
27
+ * log.info('Route registered:', method, path);
28
+ * log.warn('Deprecated route pattern detected');
29
+ * log.error('Failed to register route:', error);
30
+ * ```
31
+ */
32
+ export declare function createLogger(namespace: string): Logger;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Structured Logger
3
+ *
4
+ * Minimal logging utility that respects VELOX_LOG_LEVEL environment variable.
5
+ * Replaces raw console.* calls in library code with namespaced, level-aware logging.
6
+ */
7
+ const LEVEL_PRIORITY = {
8
+ silent: 0,
9
+ error: 1,
10
+ warn: 2,
11
+ info: 3,
12
+ debug: 4,
13
+ };
14
+ function getLogLevel() {
15
+ const env = (process.env.VELOX_LOG_LEVEL ?? 'warn').toLowerCase();
16
+ if (env in LEVEL_PRIORITY)
17
+ return env;
18
+ return 'warn';
19
+ }
20
+ /**
21
+ * Create a namespaced logger that respects VELOX_LOG_LEVEL.
22
+ *
23
+ * @param namespace - Logger namespace (e.g. 'router', 'auth')
24
+ * @returns Logger with debug/info/warn/error methods
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * import { createLogger } from '@veloxts/core';
29
+ *
30
+ * const log = createLogger('router');
31
+ * log.info('Route registered:', method, path);
32
+ * log.warn('Deprecated route pattern detected');
33
+ * log.error('Failed to register route:', error);
34
+ * ```
35
+ */
36
+ export function createLogger(namespace) {
37
+ const prefix = `[@veloxts/${namespace}]`;
38
+ function shouldLog(level) {
39
+ return LEVEL_PRIORITY[level] <= LEVEL_PRIORITY[getLogLevel()];
40
+ }
41
+ return {
42
+ debug: (...args) => {
43
+ if (shouldLog('debug'))
44
+ console.debug(prefix, ...args);
45
+ },
46
+ info: (...args) => {
47
+ if (shouldLog('info'))
48
+ console.info(prefix, ...args);
49
+ },
50
+ warn: (...args) => {
51
+ if (shouldLog('warn'))
52
+ console.warn(prefix, ...args);
53
+ },
54
+ error: (...args) => {
55
+ if (shouldLog('error'))
56
+ console.error(prefix, ...args);
57
+ },
58
+ };
59
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/core",
3
- "version": "0.6.107",
3
+ "version": "0.7.1",
4
4
  "description": "Fastify wrapper and plugin system for VeloxTS framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@fastify/static": "9.0.0",
46
- "@types/node": "25.1.0",
46
+ "@types/node": "25.2.3",
47
47
  "@vitest/coverage-v8": "4.0.18",
48
48
  "typescript": "5.9.3",
49
49
  "vitest": "4.0.18"