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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@boostercloud/serialize-config

v0.1.2

Published

Serialize your Booster Framework configuration

Downloads

7

Readme

Serialize Config for Booster Framework Injectable

Welcome to the Serialize Config component for Booster Framework's Injectable! This indispensable tool streamlines your infrastructure automation by serializing the Booster Config object into a JSON file. It allows for easy extraction of names and type information for your project's commands, events, entities, read models, and more. Serialize Config is perfect for use with automation tools like Terraform, enhancing your development workflow.

Features

  • Automation Friendly: Facilitates infrastructure as code (IaC) practices by making your Booster project's configuration accessible in JSON format.
  • Comprehensive Project Insights: Gain detailed insights into your project's commands, events, entities, read models, and more.
  • Seamless Integration: Integrate Serialize Config into your Booster project effortlessly to enhance your infrastructure automation.

Quick Start

Follow these steps to integrate Serialize Config into your Booster project:

Installation

First, install Serialize Config via npm by running the following command in your project directory:

npm install @boostercloud/serialize-config

Modify Your Config File

To ensure Serialize Config works seamlessly with your Booster project, modify your config file (src/config/config.ts) to include the injectable configuration for serialize config like so:

// your-app/src/config/config.ts
import * as SerializeConfig from '@boostercloud/serialize-config'

Booster.configure('YOUR_ENVIRONMENT_NAME', (config: BoosterConfig): void => {
  // ... other config
  config.injectable = {
    commands: [SerializeConfig.command],
  }
})

Running Serialize Config

Once you've set up Serialize Config in your Booster project, executing it is straightforward. To generate the serialized Booster configuration JSON file, run the following command from your project's root directory:

boost serialize-config -e YOUR_ENVIRONMENT_NAME

This command provides you with additional options and usage information for the Serialize Config command.

By default, the output JSON file will be saved to .booster/infra-config.json within your project directory. If you wish to specify a different output location, you can use the --output flag followed by your desired path. Here's an example command that demonstrates this:

boost serialize-config -e local --output path/to/your/custom-config.json

This flexibility allows you to integrate the serialized configuration seamlessly into your infrastructure automation workflows.

Example: Leveraging Serialize Config for automatic Terraform generation

To illustrate how Serialize Config can be used to preconfigure resources with Terraform, let’s consider a simplified example from a JSON output, focusing on a specific section named CartReadModel. This model outlines the structure and data types of a shopping cart in an e-commerce application. Here’s a snippet highlighting key properties:

"CartReadModel": {
  "properties": [
    {
      "name": "id",
      "typeInfo": {
        "name": "UUID",
        "typeGroup": "Class",
        "isNullable": false
      }
    },
    {
      "name": "testProperty",
      "typeInfo": {
        "name": "number",
        "typeGroup": "Number",
        "isNullable": false
      }
    },
    {
      "name": "cartItems",
      "typeInfo": {
        "name": "CartItem[]",
        "typeGroup": "Array",
        "isNullable": false
      }
    },
    {
      "name": "shippingAddress",
      "typeInfo": {
        "name": "Address",
        "typeGroup": "Class",
        "isNullable": true
      }
    }
  ]
}

This JSON snippet includes an identifier (id), a test property (testProperty), an array of cart items (cartItems), and a shipping address (shippingAddress). Each property has associated type information, such as UUID for the id or CartItem[] for the list of items in the cart, indicating the expected data structure and types for these fields.

Using the CartReadModel JSON for Terraform Preconfiguration

Given the CartReadModel example, you can use this structured information to preconfigure Terraform resources, ensuring that your infrastructure aligns with the application’s data models. Here’s how to approach this:

  • Define Database Schema: Extract key information from the CartReadModel to define the schema of a database table. Each property in the JSON maps to a column in the table, with the typeInfo indicating the data type.

  • Terraform Resource Definition: Use the schema information to create a Terraform resource definition for a database table. For instance, if using AWS DynamoDB, define attributes and their types based on the model’s properties.

Example Terraform configuration for the CartReadModel

resource "aws_dynamodb_table" "cart_table" {
  name           = "Cart"
  hash_key       = "id"
  billing_mode   = "PROVISIONED"

  attribute {
    name = "id"
    type = "S" # String type for UUID
  }

  attribute {
    name = "testProperty"
    type = "N" # Number
  }

  ...
}

By following these steps, developers can leverage the detailed structure provided by Serialize Config to ensure their Terraform configurations accurately reflect the application’s data models, streamlining the infrastructure setup and maintenance process.

Getting Help

Should you face any challenges or have questions regarding Serialize Config, please consult the Booster Framework documentation or join our vibrant community on the Discord server (link available in the docs). Our community and contributors are eager to assist.

Contributing

Contributions to Serialize Config are warmly welcomed. Whether it's enhancing documentation, adding features, or reporting issues, your input helps us improve. Please refer to our contributing guidelines for more information.

License

Serialize Config is open-source software licensed under the Apache License 2.0.


Dive into the world of efficient infrastructure automation with Serialize Config and elevate your Booster Framework projects to new heights!