- Add
bedrock.shutdown()
call that performs an orderly shutdown and emits various events. This differs fromexit()
andprocess.exit()
which are more immediate. - Add
bedrock.stopped
event, emitted beforebedrock.exit
. - Add documentation for
bedrock.stop
,bedrock.stopped
, andbedrock.exit
events.
- Deprecate undocumented
bedrock-cli.exit
event. Usebedrock.exit
instead. If there is use case for this specific event, please file an issue.
- Use
serialize-error@11
. No significant changes are expected.
- Replace unmaintained
uid-number
package withpasswd-user
.
- Move eslint plugin to
devDependencies
.
- Publish proper LICENSE file.
- Relicense under the Apache-2.0 license.
- Open Source under BSD-3-Clause license.
- Bump
package.json
Node.js version to 18.x (LTS).
- Fix default CLI command.
- BREAKING: A number of changes have been made to
BedrockError
to bring it more inline with modern JavaScript errors and common practice and conventions within bedrock applications. Many of these changes are unlikely to break existing applications, but they could, so they are listed here.toObject
conversion now usesserialize-error
internally for representing error stack traces.- A private or unspecified
BedrockError
, when converted to an object, now has a type ofOperationError
(instead ofbedrock.InternalServerError
. Most bedrock applications do not read or switch off of this value. - Using an array for the name of a
BedrockError
is disallowed, it must be a string. This usage is uncommon and unlikely to impact most applications. - When
BedrockError
is converted to an object, it includes bothname
andtype
(as the same value). The use ofname
is preferred, buttype
is preserved for backwards compatibility. Applications that strictly disallowed additional properties on errors will need to allow thename
property to be present, but thename
property is built into JavaScript errors and allowing for additional properties in errors is common practice such that this change is unlikely to affect many applications. Thetype
property may be removed in the future, so applications should normalize to usingname
. isType
,hasType
,hasCauseOfType
have been removed. Use the nullish coalescing operator and compare againstname
instead. Subtle mistakes can also be made by writing code that is not specific to the location that particular errors occur in a causal chain, so these functions have been removed to avoid those problems. These functions are already rarely used in modern bedrock modules and applications.
- BREAKING: Top-level variables used in computed config templates must use
valid JavaScript variable names, e.g., they cannot include hyphens (
-
) or periods (.
). A future version may remove compute config templates entirely; functions should be used instead for computed configs. - BREAKING:
config.paths.cache
andconfig.paths.log
are now listed as requiring overriding in deployments. This replaces the custom code that would log a warning if they were not set. - BREAKING: Use
commander@9
. An important change is thatbedrock.program
no longer has properties for command line options, those are accessed viabedrock.program.opts()
instead. See: https://github.com/tj/commander.js/blob/master/CHANGELOG.md - Calling
bedrock.start
more than once will cause an error to be thrown. This was already not supported and caused non-deterministic broken behavior, this change just makes it explicit and deterministic (the same clear error is always thrown). - Replace error serializer/deserializer
errio
withserialize-error
. Should not be a breaking change.
- BREAKING: Remove winston mail transport. The winston mail transport which is disabled by default and not expected to be used in any applications using 5.x has been removed.
- BREAKING: Remove
bedrock.util.callbackify
. Import from node.jsutil
if needed. - BREAKING: Remove
bedrock.util.hasValue
. - BREAKING: Remove
bedrock.util.delay
. Import from npmdelay
package if needed. - BREAKING: Remove
bedrock.util.uuid
. Import from npmuuid
package if needed. - BREAKING: Remove
bedrock.util.w3cDate
. - BREAKING: Remove
bedrock.util.isObject
. - BREAKING: Remove
bedrock.util.clone
. Import from npmklona
package if needed. - BREAKING: Remove
bedrock.util.boolify
. - BREAKING: Remove
runOnceAsync
. UserunOnce
instead. - BREAKING: Remove support for callback-based async event listeners. These are not supported and use of them may cause breakage.
- Fix imports.
- Update dependencies:
@digitalbazaar/async-node-events
.commander@2
.
- Ensure
package.json
is loaded properly.
- Update local dependencies.
- Fix winston child logger
defaultMeta
override bug. This fix was also backported to 4.5.1.
- Remove deprecated
config.core.master
.
- Remove unused dep
esm
.
- Fix
index.js
dev entry point. - Fix test coverage scripts.
- Fix
package.json
to reflect node 14.x requirement.
- Fix erroneous test import statement.
- BREAKING: Rename package to
@bedrock/core
. - BREAKING: Convert to module (ESM).
- BREAKING: Remove default export.
- BREAKING: Require node 14.x.
- Fix winston child logger
defaultMeta
override bug.
- Add
main
export that includes information about the main program module such as itsfilename
. The main program module will be properly computed on bedrock workers to express not the worker filename but the filename of the first loaded module, e.g., if an applicationfoo.js
callsbedrock.start
, thenmain
includes the full pathfilename
forfoo.js
whether running in the primary process on a worker process.
- Change internal implementation to use ESM + transpile using esm.js to CommonJS. Should be a non-breaking change.
- Ensure primary process does not exit before logger completes or errors so that the proper error code is returned.
- Ensure an orderly exit is performed when nothing else is scheduled to run on the event loop on the primary process.
- Signal handlers that prematurely terminated the primary or its workers have been refactored to allow an orderly exit. The primary and worker internal messaging and exit process has been cleaned up and simplified to help ensure more consistent outcomes and eliminate a number of bugs or unexpected states. Additionally, some unused IPC messages were removed. The expectation is that these changes do not affect existing applications except in those cases where those applications may have been exiting in inconsistent ways; the aim is for those applications to now exit the same way regardless of IPC message delivery order.
- Use
Infinity
for max event listeners instead of using0
which is a proxy for it (from docs: "The value can be set to Infinity (or 0) to indicate an unlimited number of listeners."). Link: https://nodejs.org/api/events.html#events_emitter_setmaxlisteners_n This addresses problems with libraries (such asesm
) that assumeInfinity
will be used and that make erroneous calculations if0
is used instead (e.g., theesm
library scales the max listeners fromInfinity
to1
when the intention was to increase the max listeners by just1
).
- Add new config
config.loggers.enableFileTransport
with a default oftrue
. One can disable all file based logging by setting this value tofalse
. This is useful for deployment targets such as Kubernetes that are only concerned with console logs.
- Add
unhandledRejection
handler to deal with uncaught promises by causing the process to exit.
- Replace 'master' language in process, config, and logging to use 'primary'.
- Backwards compatibility for
config.core.master
(removal planned for 5.x).
- Add POSIX signal handler to emit
bedrock.exit
event prior to exiting.
- Fix log levels in worker logger.
- Implement
ensureConfigOverride
configuration setting. This feature provides a mechanism for modules and top level applications to require that certain configuration values are changed during startup. This is useful when a deployment must use a different configuration than the development settings to be valid.
- BREAKING: Use Winston logger 3.x. Bedrock configs for the various loggers
are passed directly into the Winston logger constructors where there have
been numerous breaking changes. This applies to config objects suchs as
config.loggers.console
. See: https://github.com/winstonjs/winston/blob/master/UPGRADE-3.0.md - Various log formatters may be specified via the Bedrock config. The 'default'
formatter produces logs that are equivalent to Bedrock 3.x. Custom
formatters must conform to the
logform
API. See: https://github.com/winstonjs/logform
// formatter options:
// default, json, logstash or a custom formatter function
config.loggers.console.bedrock.formatter = 'default';
- Replace
lodash
dependency with standalone per method packages.
- Add unique
workerId
per process.
- Log
signal
when workers exit.
- Update winston-mail dependency.
- Use GitHub Actions for CI testing.
- Update dependencies.
- Use workaround for master/worker child logger issue.
- Switch from
getpwnam
inposix
touid-number
package.
- Update bedrock-test dependency.
- BREAKING: Update Node.js requirement to v10.12.0.
- BREAKING:
bedrock.start()
now returns a promise instead of using a callback. Top-level code using the callback should change toasync
/await
orthen
/catch
as needed. - BREAKING: Update
async-node-events
dependency and update events API.emit
is now an async function and used instead of passing a callback for completion. User code must be updated for this change. It is suggested to await theemit
calls and use async listeners or Promises.
- BREAKING:
runOnce
callback form is removed in favor of therunOnceAsync
implementation.runOnceAsync
remains as an alias forrunOnce
but is deprecated. Quick fix is to wrap the newrunOnce
withcallbackify
and thefn
param withpromisify
. - Use master/worker child loggers.
bedrock.events.emit
wrapper. Using default fromasync-node-events
.- BREAKING: Deprecated event object style.
- BREAKING: Remove mocha unit test framework. The test framework now resides entirely in the bedrock-test module@4.
- BREAKING: Remove
bedrock.jsonld
and related configuration. A jsonld document loader is now available in bedrock-jsonld-document-loader@1.
bedrock.util.hasValue
helper API to replacejsonld.hasValue
.
- Fix memory leak and improve error handling in
runOnce
andrunOnceAsync
.
- Update lodash to 4.17.14.
- Switch to eslint.
- BREAKING: Update Node.js engine requirement to >= 8. Note this is due to the use of async/await when runOnceAsync was added in 1.16.0.
- Improve callback function detection in
events.emit
API.
bedrock.runOnceAsync
API which is a promise based version ofbedrock.runOnce
.
bedrock.util.delay
API which is used to create a promise which resolves after the specified milliseconds.
- Use
uuid-random
forbedrock.util.uuid
.
- Change default value of
bedrock.config.jsonld.strictSSL
fromfalse
totrue
. This means that thejsonld
library's document loader will refuse to retrieve documents from sites without proper SSL certificates. This change will impact unit tests in Bedrock modules. ThestrictSSL
flag will need to be set tofalse
in thetest.config.js
files for affected modules.
- Add
bedrock-cli.parsed
event.
- Update copyright notices.
- Style fixes.
- Update async-node-events to 1.0.0.
- Return Promise from
events.emit
andevents.emitLater
that resolves toundefined
once the event has been emitted to all listeners or tofalse
if it was canceled.
- Add
util.callbackify
helper to produce functions that can be called with a callback function or that will return a Promise if the callback function is omitted. This utility function is used in bedrock modules that are written using Promises internally and that expose Promise-based public APIs that also support legacy callback patterns.
--log-exclude
option to eliminate logging from certain modules.
- Update to newer worker API.
- Improve errors in runOnce calls.
- Use logger to handle uncaught error formatting.
- Update from istanbul to nyc for coverage.
- Update jsonld to 1.0.0.
- Update jsonld to 0.5.x.
- Update many other dependencies.
--log-only
option to log only certain modules.
- Update mocha dependency which addresses multiple security vulnerabilities.
- Add
assertNoError(err)
global test helper which makes an assertion thaterr
should be falsy. If an error does occur, the full error will be logged to the console. The additional logging is helpful when troubleshooting tests that are failing due to a regression. This helper should be used in place of the commonly usedshould.not.exist(err)
assertion.
- Upgrade test related dependencies: mocha, chai, chai-as-promised.
- Add
child(meta)
method to create a child logger with common metadata for each logging call. The specialmodule
meta key can be used to prefix messages with[module]
and is removed from the message details.child(name)
is a shortcut forchild({module: name})
.
- Deprecated default values for
config.paths
. A warning will be printed. A future major version will force values to be set by applications.
- Add
config.paths
withlog
andcache
entries. This is designed to be a simple single point of configuration for the root logging and cache paths.
- Use computed configs:
- Add common cache and log paths to config.paths.
- Use common log path for default log files.
- Add
bedrock.util.config
utilities:- Add
bedrock.util.config.Config
OO wrapper API. - Common
bedrock.util.config.main
Config wrapper forbedrock.config
. - See README for usage details.
- Add
- ci-test target with tap mocha reporter.
- Updated dependencies.
- Updated to node >= 6.
- Fix chown bug when posix doesn't exist and usernames are used.
- Improve logging of simple object unhandled errors.
- Use improved common uncaught exception handler.
- Update docs.
- Update jscs linter rules.
enableChownDir
check typo.
bedrock.config.loggers.*.bedrock
for bedrock specific options.- Add
...bedrock.enableChownDir
boolean option to controlchown
ing file logger directory to runtime userId.
- Check
config.loggers
properties are Objects before accsesing sub-properties. Fixes older configs that set other non-Object meta-data along with loggers.
- Add simpler and more explicit mechanism for adding new winston transports.
Now a call to
bedrock.loggers.addTransport
can be made in event listeners handling thebedrock-loggers.init
event.
- Updated dependencies.
- Updated jsonld.js to 0.4.2 to get URDNA2015 support.
- Initialize jsonld document loader in
bedrock.init
event phase. Done to allow access to fully setup config. Warn if default document loader is used before jsonld initialized.
bedrock.config.jsonld.strictSSL
used if available to configure jsonld document loader.
exit
now calls worker kill() vs disconnect() and process.exit(). Appears to be more correct and works around a bug in node 4.x.
- Update posix version to be compatible with node 4.0.0.
- Updated jsonld and other versions.
- Updated async to version 1.4.x.
- Bug that caused workers to not be restarted.
- Handle cycles in log message meta data.
- Update dependencies.
- BREAKING: A new event
bedrock.admin.init
was introduced that emits prior tobedrock.init
. This new event is emitted while the process has any elevated privileges and after it is handled, elevated privileges are dropped. This changesbedrock.init
so that it runs without elevated privileges. This only affectedbedrock.server
in a negative way; this module has been updated to comply with the change. Also,bedrock.init
should no longer be used to emit custom events; these should be deferred tobedrock.start
to prevent scenarios where a listener of an event emitted by one module can't use the API of another unrelated module because it hasn't been initialized yet. Deferring custom event emitting tobedrock.start
as a best practice avoids this scenario. - Updated JSCS rules.
- Fixed default command after upgrade to commander 2.6.
- Updated commander to version 2.6.0.
- Major package reorganization:
- Files split into many sub-projects.
- Bedrock server split into
bedrock-*
modules. - Bedrock frontend components split into
bedrock-angular-*
modules.
- Infrastructure changed to make composing a project from modules much easier.
- bedrock:
- New event system for module initialization and communication.
- Removed old bedrock.modules API.
config.app.*
changed toconfig.core.*
.config.server.workers
changed toconfig.core.workers
.- Various code moved to modules or removed (
iso8601
library, etc) bedrock.security
API removed. Other libraries such asjsonld-signatures
can be used.bedrock.tools
renamed tobedrock.util
;bedrock.tools
is deprecated.- Config files:
- Most files moved as examples in
bedrock-seed
. - Some values added as defaults in appropriate modules.
configs
dir removed.- Development uses defaults.
- Testing uses
lib/test.config.js
.
- Most files moved as examples in
- Removed
config.environment
in favor of feature flags. config.core.starting.groupId
andconfig.core.starting.userId
used for master before logging initialized.config.core.running.groupId
andconfig.core.running.userId
used for master and workers after logging initialized.config.core.errors.showStack
used to control general error stack traces.config.jsonld.strictSSL
used to control strict SSL of jsonld library.config.views.serviceUnavailable
to control 503 Service Unavailable for all requests.config.core.masterTitle
changed toconfig.core.master.title
.config.core.workerTitle
changed toconfig.core.worker.title
.config.core.restartWorkers
changed toconfig.core.worker.restart
.- Remove uses of
MODULE_NS
. - Remove prefixes from errors and use simpler names.
- Change many
*NotFound
error types to justNotFound
.
- mail:
- Per-module mapper files removed.
- Modules push event handlers to
bedrock.config.mail.events
array:{type: 'EVENT-TYPE', template: 'TEMPLATE-HANDLER-ID'}
- Modules set config objects in
bedrock.config.mail.templates.config[ID]
:{filename: 'FULL-FILENAME', [disabled: true]}
- express:
config.server.cache.*
renamed toconfig.express.cache.*
.config.server.session.*
renamed toconfig.express.session.*
.config.server.static
renamed toconfig.express.static
.config.server.staticOptions
renamed toconfig.express.staticOptions
.config.express.useSession
to control session support.config.express.dumpExceptions
to control error exceptions.config.express.showStack
to control error stack traces.
- i18n:
config.website.i18nPaths
renamed toconfig.i18n.localePath
.config.website.writeLocales
renamed toconfig.i18n.writeLocales
.
- schemas:
- Schemas moved to
bedrock-validation
and other modules. - Modules push paths to
bedrock.config.validation.schemas.paths
array.
- Schemas moved to
- mongodb:
config.database
changed toconfig.mongodb
.bedrock-mongodb
module now uses version 2.x of the Node.js driver, see Migrating to 2.X.- Support for mongodb 2.2 has been dropped.
- cli:
-R/--reporter
changed to--mocha-reporter
.
- views:
config.website.views
moved toconfig.views
.config.views.vars
are now shared between client and server templates except for any vars under_private
which are server-only.config.views.vars.clientData
has been removed.config.views.vars.session
moved toconfig.views.vars.idp.session
.- A number of unused keys in
config.views.vars
have been removed:session.auth
,session.loaded
,serviceHost
,serviceDomain
,productionMode
.
- See git history for changes.