@lamware/appconfig
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published
NPM Discord Apache-2.0

Lamware - AWS AppConfig

This Lamware Middleware utilizes an API exposed by the AWS Lambda AppConfig Layer Extension to pull-down a copy of an AppConfig configuration and allows you to easily provide TypeScript typings for it.

Installation

This package is available via NPM:

yarn add @lamware/appconfig

# or

npm install @lamware/appconfig

Usage

import type { APIGatewayProxyHandlerV2 } from 'aws-lambda';
import { appconfig } from '@lamware/appconfig';
import { lamware } from '@lamware/core';

interface AppConfig {
  helloWorld: string;
}

const { handler } = lamware<APIGatewayProxyHandlerV2<any>>()
  /**
   * You can provide an Interface to the middleware to automatically type
   * the config in the handler `execute`.
   **/
  .use(appconfig<AppConfig>({
    // Ensure you provide the info required to pull down a configuration.
    app: 'evilkiwi-api',
    env: 'production',
    config: 'production',
    // You can also optionally provide an override URL for the AppConfig API.
    url: 'http://localhost:2772', // The default, provided by the AppConfig Lambda Extension.
  }))
  .execute(async ({ state }) => {
    return {
      statusCode: 200,
      body: JSON.stringify({
        debug: state.config.helloWorld,
      }),
    };
  });

export { handler };

Package Sidebar

Install

npm i @lamware/appconfig

Weekly Downloads

31

Version

2.0.1

License

GPL-3.0-only

Unpacked Size

40.5 kB

Total Files

7

Last publish

Collaborators

  • oyed