> ⚠️ **Note:** This package relies heavily on environment variables for configuration. Ensure that all required variables are properly set in your environment to prevent runtime errors or unexpected behavior.
npm install @media-premade/ms-common> ⚠️ Note: This package relies heavily on environment variables for configuration. Ensure that all required variables are properly set in your environment to prevent runtime errors or unexpected behavior.
a reusable library designed to streamline common operations such as database connections, logging, and event handling. It is optimized for use in projects under the media-premade ecosystem.
1. Installation
2. Usage
3. Configuration
4. Publishing the Package
5. Deployment
``bash`
pnpm add @media-premade/ms-common
`javascript
import msCommon from "@media-premade/ms-common";
import { logger } from "@media-premade/ms-common/lib/logger";
// Initialize msCommon and use logger
logger.info("msCommon initialized successfully!");
`
This library uses environment variables to configure its behavior. Below is a list of supported variables, their purposes, and defaults:
| Variable | Default | Description | Valid Values |
| ---------------- | --------------- | ------------------------------------ | ----------------------------------- |
| NODE_ENV | development | Defines the runtime environment. | development, production, test |WRITE_LOG_FILE
| | false | Enable/disable writing logs to file. | true, false |LOG_AS_JSON
| | false | Format logs as JSON. | true, false |LOG_LEVEL
| | debug | Set the logging verbosity level. | debug, info, warn, error |JWT_SECRET
| | "some_secret" | Secure key for JWT operations. | Any string |
Note: Always ensure environment variables are explicitly set in production environments to avoid unexpected behavior.
Follow these steps to publish the package to the npm registry:
1. Ensure you are logged into the npm registry:
`bash`
pnpm adduser
2. Confirm you have the necessary permissions to publish the package.
1. Build the Package
`bash`
pnpm build
2. Version the Package
Increment the version based on the type of release:
- Patch (e.g., 1.0.0 → 1.0.1):`
bash`
pnpm version patch
1.0.0
- Minor (e.g., → 1.1.0):`
bash`
pnpm version minor
1.0.0
- Major (e.g., → 2.0.0):`
bash`
pnpm version major
3. Publish
Publish the package to the npm registry:
`bash`
pnpm publish --no-git-checks
Ensure all required environment variables are set correctly.
1. Build the package:
`bash`
pnpm build
2. Publish the package following the steps above.
3. Update consuming projects with the latest version:
`bash``
pnpm add @media-premade/ms-common