npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cmp-aws-database

v2.1.4

Published

The package "cmp-aws-database" is for its database, which defines global tables. These tables are designed to be imported and used across multiple applications of "craft-my-plate."

Readme

Craft My Plate Database Package

A comprehensive, environment-aware database package for the Craft My Plate application ecosystem. This package provides DynamoDB-based data access with automatic environment configuration.

🚀 Features

  • Environment-Aware Configuration: Automatically adapts to development, staging, production, and test environments
  • Dynamic Table Naming: Environment-specific table prefixes (dev-, staging-, test-)
  • Feature Flags: Environment-specific feature toggles (parallel processing, caching, etc.)
  • TypeScript Support: Full TypeScript definitions and type safety
  • AWS CDK Integration: Infrastructure as Code for database tables
  • Comprehensive DAO Layer: Generic data access objects with environment-specific optimizations

📦 Installation

npm install cmp-aws-database

🎯 Quick Start

Basic Usage

import { 
  envManager, 
  TABLE_NAMES, 
  UserModel, 
  userDAO 
} from 'cmp-aws-database';

// Check current environment
console.log('Environment:', envManager.getEnvironment());

// Use environment-aware table names
const userTableName = TABLE_NAMES.USER;

// Create and save a user
const user = new UserModel();
user.userId = 'user123';
user.email = '[email protected]';

const savedUser = await userDAO.save(user, { userSub: 'auth-user-123' });

Environment Configuration

The package automatically detects the environment based on NODE_ENV or ENVIRONMENT variables:

# Development
export NODE_ENV=development

# Staging  
export NODE_ENV=staging

# Production
export NODE_ENV=production

# Test
export NODE_ENV=test

🌍 Environment-Specific Behavior

DEV Environment

  • Database: Local DynamoDB (http://localhost:8000)
  • Table Prefix: dev-
  • Features: Sequential processing, no caching
  • Logging: Debug level
  • Branch: environment/DEV
  • NPM Tag: @dev

PRODDEBUG Environment

  • Database: AWS DynamoDB
  • Table Prefix: proddebug-
  • Features: Parallel processing, caching enabled
  • Logging: Info level
  • Branch: environment/PRODDEBUG
  • NPM Tag: @proddebug

PROD Environment

  • Database: AWS DynamoDB
  • Table Prefix: None (empty)
  • Features: Parallel processing, caching enabled
  • Logging: Warn level
  • Branch: environment/PROD
  • NPM Tag: @latest

Test Environment

  • Database: Local DynamoDB (http://localhost:8000)
  • Table Prefix: test-
  • Features: Sequential processing, no caching
  • Logging: Error level

📚 Available Models and DAOs

Customer User Models

  • UserModel / userDAO
  • OrderModel / orderDao
  • CartModel / cartDAO
  • WalletModel / walletDao
  • PaymentModel / paymentDao
  • And many more...

Internal User Models

  • InternalUserModel / internalUserDao
  • ActivityLogsModel / activityLogsDao
  • QuotationsModel / quotationsDao

🔧 Advanced Usage

Environment-Specific Features

import { envManager } from 'cmp-aws-database';

const config = envManager.getConfig();

// Check if parallel processing is enabled
if (config.features.enableParallelProcessing) {
  await userDAO.parallelBatchGet(users);
} else {
  await userDAO.batchGet(users);
}

// Check if caching is enabled
if (config.features.enableCaching) {
  // Implement caching logic
}

Custom Table Names

import { TableNameManager } from 'cmp-aws-database';

const customTableName = TableNameManager.getTableName('MyCustomTable');
// Returns: dev-MyCustomTable, staging-MyCustomTable, or MyCustomTable

Environment Override (Testing)

import { envManager } from 'cmp-aws-database';

// Override environment for testing
envManager.setEnvironment('test');

🏗️ Infrastructure

CDK Stack Deployment

import { CustomerAppDbStack, InternalUserDbStack } from 'cmp-aws-database';

// Deploy customer app database
const customerStack = new CustomerAppDbStack(app, 'CustomerAppDbStack');

// Deploy internal user database  
const internalStack = new InternalUserDbStack(app, 'InternalUserDbStack');

Available Tables

The package includes pre-configured tables for:

  • User management
  • Order processing
  • Payment handling
  • Inventory management
  • Analytics and reporting
  • And much more...

🔍 Debugging

Environment Information

import { envManager } from 'cmp-aws-database';

console.log('Current environment:', envManager.getEnvironment());
console.log('Database config:', envManager.getDatabaseConfig());
console.log('Features enabled:', envManager.getConfig().features);

Table Name Resolution

import { TABLE_NAMES, BASE_TABLE_NAMES } from 'cmp-aws-database';

console.log('Environment-aware table names:', TABLE_NAMES);
console.log('Base table names:', BASE_TABLE_NAMES);

📋 Migration Guide

From Hardcoded Configuration

Before:

const tableName = 'UserTable';
const client = new DynamoDB({ maxAttempts: 10 });

After:

import { TABLE_NAMES, DatabaseFactory } from 'cmp-aws-database';

const tableName = TABLE_NAMES.USER;
const client = DatabaseFactory.getDynamoDBClient();

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

📄 License

Apache-2.0

🆘 Support

🌿 Branch-Based Publishing Strategy

Branch Structure

master (main development)
├── environment/DEV (DEV environment)
├── environment/PRODDEBUG (PRODDEBUG environment)
└── environment/PROD (PROD environment)

Publishing Workflow

1. Create Environment Branches

# Create all environment branches
npm run create-branches

2. DEV Environment Publishing

# Switch to DEV branch
git checkout environment/DEV

# Make changes and commit
git add .
git commit -m "Add new feature for DEV"
git push origin environment/DEV

# Publish to npm with @dev tag
npm run deploy:dev

Result: cmp-aws-database@dev (version: 1.1.107-dev.1)

3. PRODDEBUG Environment Publishing

# Switch to PRODDEBUG branch
git checkout environment/PRODDEBUG

# Promote changes from DEV
./scripts/git-workflow.sh promote DEV PRODDEBUG

# Publish to npm with @proddebug tag
npm run deploy:proddebug

Result: cmp-aws-database@proddebug (version: 1.1.107-proddebug.1)

4. PROD Environment Publishing

# Switch to PROD branch
git checkout environment/PROD

# Promote changes from PRODDEBUG
./scripts/git-workflow.sh promote PRODDEBUG PROD

# Publish to npm with @latest tag
npm run deploy:prod

Result: cmp-aws-database@latest (version: 1.1.107)

Installation Commands

# Install DEV version
npm install cmp-aws-database@dev

# Install PRODDEBUG version
npm install cmp-aws-database@proddebug

# Install PROD version (latest)
npm install cmp-aws-database@latest

🔄 Version History

  • 1.1.107: Current version with environment-aware configuration
  • Previous versions: Legacy hardcoded configuration

Note: This package uses branch-based publishing where each environment has its own branch and publishes with different NPM tags. The same package name is maintained across all environments while providing environment-specific configurations.