Lamware Middleware to asynchronously load AppConfig
npm install @lamware/appconfigThis 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.
This package is available via NPM:
``bash
yarn add @lamware/appconfig
npm install @lamware/appconfig
`
`typescript
import type { APIGatewayProxyHandlerV2 } from 'aws-lambda';
import { appconfig } from '@lamware/appconfig';
import { lamware } from '@lamware/core';
interface AppConfig {
helloWorld: string;
}
const { handler } = lamware
/**
* You can provide an Interface to the middleware to automatically type
* the config in the handler execute.
**/
.use(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 };
``