A comprehensive collection of shared libraries providing common services, utilities, and tools for AWS Lambda applications and Node.js projects.
- Overview
- Architecture
- Services
- Utilities
- Installation
- Usage
- API Reference
- Publishing
- Development
- Contributing
- License
The Tale of DDH Libraries is a monorepo containing modular packages designed to accelerate development of serverless applications and Node.js services. Each package is independently versioned and can be used standalone or as part of the complete suite.
- Modular Architecture: Each service and utility is a separate package
- AWS Lambda Optimized: Built specifically for serverless environments
- TypeScript Support: Full type definitions and modern ES modules
- Comprehensive Testing: Built-in testing utilities and patterns
- Production Ready: Battle-tested in production environments
The library is organized into two main categories:
taleofddh-lib/
├── services/ # AWS service wrappers and integrations
└── utilities/ # Common utilities and helpers
Provides high-level wrappers for AWS services and third-party integrations, designed for Lambda functions.
Contains common utilities, helpers, and middleware for application development.
The services package includes the following modules:
| Service | Description | Version |
|---|---|---|
| channel | Communication channel management | 3.0.1 |
| crypto | Cryptographic operations and utilities | 3.0.1 |
| database | Database connection and query utilities | 3.0.1 |
| distribution | Content distribution and delivery services | 3.0.1 |
| drive | Google Drive integration | 3.0.1 |
| Email service integration and utilities | 3.0.1 | |
| gmail | Gmail API wrapper | 3.0.1 |
| identity | Identity and authentication services | 3.0.1 |
| message | Message processing and handling | 3.0.1 |
| notification | Push notification services | 3.0.1 |
| secret | AWS Secrets Manager integration | 3.0.1 |
| storage | AWS S3 and storage utilities | 3.0.1 |
| tickettailor | TicketTailor API integration | 3.0.1 |
| WhatsApp Business API wrapper | 3.0.1 | |
| workbook | Excel/spreadsheet processing | 3.0.1 |
The utilities package provides the following modules:
| Utility | Description | Key Functions | Version |
|---|---|---|---|
| array | Array manipulation utilities | distinctValues, groupBy, sortBy, chunk |
3.0.1 |
| constants | Application constants and enums | HTTP_STATUS, ERROR_CODES, AWS_CONFIG |
3.0.1 |
| date | Date formatting and manipulation | formatForDisplay, addDays, daysDifference |
3.0.1 |
| error | Error handling and classification | classifyError, asyncHandler, custom error classes |
3.0.1 |
| logger | Structured logging utilities | Configurable logging with levels | 3.0.1 |
| middleware | Express/Lambda middleware | corsMiddleware, validationMiddleware, authMiddleware |
3.0.1 |
| response | HTTP response helpers | createResponse, createErrorResponse, CORS headers |
3.0.1 |
| text | Text processing utilities | String manipulation and formatting | 3.0.1 |
| validation | Input validation helpers | validateEmail, validateUUID, sanitizeInput |
3.0.1 |
First, configure npm to use the GitHub package registry for @taleofddh packages:
# Add to your ~/.npmrc file
echo "@taleofddh:registry=https://npm.pkg.github.com/" >> ~/.npmrcYou'll also need to authenticate with GitHub. See GitHub Packages documentation for authentication details.
npm install @taleofddh/libraries# Services
npm install @taleofddh/services
# Utilities
npm install @taleofddh/utilities
# Individual packages
npm install @taleofddh/response @taleofddh/validationWe provide a unified package manager that handles both development and production scenarios:
# Install complete development environment
npm run install:all
# List available packages
npm run list# Development setup
node scripts/install-packages.js # Complete environment
node scripts/install-packages.js services # Only services
node scripts/install-packages.js utilities # Only utilities
# List packages
node scripts/install-packages.js list// Import all services
import * as services from '@taleofddh/services';
const { gmail, storage, notification } = services;
// Import all utilities
import * as utilities from '@taleofddh/utilities';
const { createResponse, validateEmail, Logger } = utilities;// Response utilities
import { createResponse, createErrorResponse } from '@taleofddh/utilities';
export const handler = async (event) => {
try {
const result = await processRequest(event);
return createResponse(200, result);
} catch (error) {
return createErrorResponse(error);
}
};import { validateEmail, validateRequired } from '@taleofddh/utilities';
const validateUserInput = (data) => {
const errors = [];
if (!validateRequired(data.name)) {
errors.push('Name is required');
}
if (!validateEmail(data.email)) {
errors.push('Valid email is required');
}
return errors;
};import { corsMiddleware, validationMiddleware } from '@taleofddh/utilities';
export const handler = corsMiddleware(
validationMiddleware(
async (event) => {
// Your handler logic
return createResponse(200, { message: 'Success' });
}
)
);// Success responses
createResponse(statusCode, data, headers?)
createCreatedResponse(data, headers?)
createNoContentResponse(headers?)
// Error responses
createErrorResponse(error, headers?)
createValidationErrorResponse(errors, headers?)
createNotFoundResponse(message?, headers?)
createUnauthorizedResponse(message?, headers?)// Basic validation
validateRequired(value)
validateEmail(email)
validateUUID(uuid)
validatePhone(phone)
// Advanced validation
validateStringLength(str, min, max)
validateNumber(value, min?, max?)
validateEnum(value, allowedValues)
validateArray(arr, itemValidator?)// Custom error classes
NotFoundError(message)
ConflictError(message)
UnauthorizedError(message)
ValidationError(message, details?)
// Error utilities
classifyError(error)
asyncHandler(fn) // Wraps async functions for error handling- Node.js >= 24.0.0
- npm >= 11.0.0
# Clone the repository
git clone https://github.com/taleofddh/taleofddh-lib.git
# Complete development environment setup (recommended)
cd taleofddh-lib
npm run install:all# Install complete development environment
npm run install:all# Install dependencies
npm run install:all # Install complete development environment
npm run install:services # Install only services packages
npm run install:utilities # Install only utilities packages
# List available packages
npm run list
# Update version (no git operations)
npm run version:patch # 1.0.0 → 1.2.3 (bug fixes)
npm run version:minor # 1.0.0 → 1.3.0 (new features)
npm run version:major # 1.0.0 → 2.0.0 (breaking changes)
# Configure packages for GitHub registry
npm run configure
# Publish packages
npm run publish:all # Publish all packages
npm run publish:services # Publish only services
npm run publish:utilities # Publish only utilities- Patch (
1.0.0 → 1.2.3): Bug fixes, small improvements, no breaking changes - Minor (
1.0.0 → 1.3.0): New features, enhancements, backward compatible - Major (
1.0.0 → 2.0.0): Breaking changes, API changes, major updates
# Run tests (when available)
npm test
# Run tests for specific package
cd services && npm test
cd utilities && npm testtaleofddh-lib/
├── services/
│ ├── channel/
│ ├── crypto/
│ ├── database/
│ ├── distribution/
│ ├── drive/
│ ├── email/
│ ├── gmail/
│ ├── identity/
│ ├── message/
│ ├── notification/
│ ├── secret/
│ ├── storage/
│ ├── tickettailor/
│ ├── whatsapp/
│ ├── workbook/
│ └── index.js
├── utilities/
│ ├── array/
│ ├── constants/
│ ├── date/
│ ├── error/
│ ├── logger/
│ ├── middleware/
│ ├── response/
│ ├── text/
│ ├── validation/
│ └── index.js
├── scripts/
│ ├── configure-packages.js
│ ├── install-packages.js
│ ├── publish-packages.js
│ └── version-manager.js
├── package.json
└── README.md
# Run tests (when available)
npm test
# Run tests for specific package
cd services && npm test
cd utilities && npm testThis repository uses automated publishing to GitHub Packages with intelligent change detection and individual package publishing.
- Development: Work on code using
npm run install:all - Version Update: Use
npm run version:patchto update all package versions - Publishing:
- Automatic: Push to
productionbranch triggers GitHub Actions - Manual: Use
npm run publish:allto publish immediately
- Automatic: Push to
- Clean Packages: Published packages are clean, tagged versions without dev dependencies
- Registry: Packages are published to GitHub npm package registry
- Published Versions: Clean packages available from
https://npm.pkg.github.com/ - Tagged Releases: Specific versions (e.g., v1.0.0) not development code
- Production Dependencies: Only runtime dependencies, no dev dependencies
- Proper Versioning: Semantic versioning with dependency resolution
- Authentication Required: Requires GitHub authentication to access registry
- GitHub Personal Access Token: You need a GitHub PAT with
write:packagespermission - npm Configuration: Your
~/.npmrcshould be configured with:@taleofddh:registry=https://npm.pkg.github.com/ //npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN
The repository contains three types of packages:
- Main Package:
@taleofddh/libraries- The root package - Aggregate Packages:
@taleofddh/services- Aggregates all service packages@taleofddh/utilities- Aggregates all utility packages
- Individual Packages: Each service and utility is a separate package (22+ packages)
The GitHub Actions workflow automatically publishes packages when:
-
Push to production branch with changes in:
services/**utilities/**.github/workflows/publish-packages.yml
-
Manual workflow dispatch with options:
all: Publish all packagesservices: Publish only service packagesutilities: Publish only utility packagesindividual: Publish specific package (specify package name)
- Change Detection: Only publishes packages that have changed
- Individual Package Publishing: Publishes each changed package separately
- Aggregate Publishing: Publishes aggregate packages when their components change
- Main Package Publishing: Publishes main package when aggregates are updated
# Configure all packages for GitHub registry
npm run configure
# Publish all packages
npm run publish:all
# Publish only services
npm run publish:services
# Publish only utilities
npm run publish:utilities# Publish all packages
node scripts/publish-packages.js all
# Publish only services
node scripts/publish-packages.js services
# Publish only utilities
node scripts/publish-packages.js utilities# Navigate to specific package and publish
cd services/gmail
npm publish
# Or utilities
cd utilities/response
npm publishUse the provided npm scripts to update versions across all packages:
# Patch version (1.0.0 -> 1.2.3)
npm run version:patch
# Minor version (1.0.0 -> 1.3.0)
npm run version:minor
# Major version (1.0.0 -> 2.0.0)
npm run version:majorUpdate versions in individual package.json files as needed.
All packages are configured with:
{
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
}
}This ensures packages are published to the GitHub registry.
- Verify your GitHub token has
write:packagespermission - Check your
~/.npmrcconfiguration - Ensure you're authenticated with GitHub
- Check package versions (can't republish same version)
- Verify package.json syntax
- Ensure all dependencies are available
- Check GitHub Actions logs for detailed error messages
If packages aren't appearing in GitHub Packages:
- Verify the package name matches the repository owner
- Check that
publishConfig.registryis set correctly - Ensure the repository has packages enabled
- Version Consistency: Keep related packages in sync
- Change Detection: Let GitHub Actions handle automatic publishing
- Testing: Test packages locally before publishing
- Documentation: Update README.md when adding new packages
- Dependencies: Ensure all dependencies are properly declared
Monitor package publishing through:
- GitHub Actions: Check workflow runs in the Actions tab
- GitHub Packages: View published packages in the repository's Packages tab
- npm logs: Check local npm publish output for errors
We welcome contributions! Please see our contributing guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow existing code style and patterns
- Add tests for new functionality
- Update documentation as needed
- Ensure all packages maintain compatibility
- Use semantic versioning for releases
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Devadyuti Das
Built with ❤️ for the serverless community