@moreapp/common-nodejs v0.7.13
MoreApp Common Node.js
This project contains common code that can be used for our Node.js projects.
Getting started
Run yarn prepare
once to install Git hooks, doing lints and prettier formatting
Project usage
Most code can be used as is, except for tracing, see below.
Tracing
Tracing code should always be loaded (import
/require
) first, before any other libraries. This is because the
OpenTelemetry instrumentations monkey patch libraries to add tracing. Patching has to happen first, because already
loaded libraries will be cached by the module system.
The recommended way to do this, is to create a file instrumentation.ts
with the following content (the extra
instrumentation is there as an example):
import { tracer } from "@moreapp/common-nodejs";
import { MongoDBInstrumentation } from "@opentelemetry/instrumentation-mongodb";
tracer("<SERVICE_NAME>", {
extraInstrumentations: [new MongoDBInstrumentation()],
});
And then use the --require
Node.js CLI option to load this file.
Creating a new release
Follow the steps below to create a new release:
- Ensure that the
master
branch has the commits you want to release - Start a new build in Bitbucket Pipelines for the
master
branch with thecreate-release
pipeline - Select which type of version bump you want to do
- The build will automatically create a new version and publish it to NPM
Creating a local release
If you want to test new code in other projects, then you can link this repository using Yarn
.
- Run
yarn link
in this repository - Run
yarn link @moreapp/common-nodejs
in the project you want to use this repository in