Skip to content

Repository files navigation

@eliware/common

A small ESM convenience package that provides one stable import surface for Eliware's shared Node.js utilities.

Requirements

  • Node.js 26 or newer
  • Published Eliware dependency packages matching the versions in package.json

Installation

npm install @eliware/common

Exports

@eliware/common re-exports the current public APIs from:

  • @eliware/log: log, createLogger, safeSerialize
  • @eliware/path: path, pathUrl, getCurrentDirname, getCurrentFilename, resolvePath, relativePath, fileUrlToPath
  • @eliware/errors: registerHandlers
  • @eliware/signals: registerSignals
  • Node.js fs

The implementation is split into focused modules under src/ while the package root remains the public entry point.

Usage

import{fs,log,path,pathUrl,resolvePath,registerHandlers,registerSignals,}from'@eliware/common';constconfigPath=path(import.meta,'.env');constconfigUrl=pathUrl(import.meta,'.env');constabsolutePath=resolvePath(import.meta,'config');log.info('Application starting',{ configPath, configUrl, absolutePath });log.info(`Files: ${fs.readdirSync(path(import.meta)).join(', ')}`);consterrors=registerHandlers({events: ['uncaughtException','unhandledRejection']});constsignals=registerSignals({shutdownHook: async()=>errors.removeHandlers()});process.once('SIGTERM',()=>voidsignals.shutdown('SIGTERM'));

TypeScript

Type declarations are included and expose the dependency option and return types:

import{createLogger,getCurrentDirname,registerSignals,typeRegisterSignalsOptions,}from'@eliware/common';constlogger=createLogger({format: 'json'});constdirectory=getCurrentDirname(import.meta);constoptions: RegisterSignalsOptions={exit: false};constregistration=registerSignals(options);

Errors / Troubleshooting

This package is a compatibility layer and delegates behavior to its underlying packages. For logging, path, error-handler, or signal-handler failures, consult the corresponding dependency documentation. Keep dependency versions synchronized with the public exports and declarations.

Development

npm install
npm test
npm run lint
npm run test:gaps
npm run typecheck
npm run pack

This package is a re-export/compatibility layer. Its tests verify the public export contract and representative delegation to the underlying packages; implementation behavior is tested in those dependency packages.

Security

Do not log secrets or include credentials or machine-specific paths in examples. Review delegated package behavior and keep dependencies updated before publishing.

Links

License

MIT

About

An ESM/Jest/Node-friendly utility for resolving file and directory paths, logging, error handling, and signal handling in both CommonJS and ESM environments.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages