@media-premade/ms-common
v1.0.55
Published
> ⚠️ **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.
Readme
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.
Table of Contents
Installation
pnpm add @media-premade/ms-commonUsage
Basic Example
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!");Configuration
Required Environment Variables
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.
Publishing the Package
Follow these steps to publish the package to the npm registry:
Prerequisites
Ensure you are logged into the npm registry:
pnpm adduserConfirm you have the necessary permissions to publish the package.
Steps to Publish
Build the Package
pnpm buildVersion the Package Increment the version based on the type of release:
- Patch (e.g.,
1.0.0→1.0.1):pnpm version patch - Minor (e.g.,
1.0.0→1.1.0):pnpm version minor - Major (e.g.,
1.0.0→2.0.0):pnpm version major
- Patch (e.g.,
Publish Publish the package to the npm registry:
pnpm publish --no-git-checks
Deployment
Environment Preparation
Ensure all required environment variables are set correctly.
Steps to Deploy
Build the package:
pnpm buildPublish the package following the steps above.
Update consuming projects with the latest version:
pnpm add @media-premade/ms-common
