{"id":34714790,"url":"https://github.com/rlmartin/config-loader","last_synced_at":"2026-01-29T04:13:48.172Z","repository":{"id":154444064,"uuid":"631563895","full_name":"rlmartin/config-loader","owner":"rlmartin","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-14T21:31:48.000Z","size":220,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-02T14:43:49.722Z","etag":null,"topics":["aws","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rlmartin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-04-23T12:27:10.000Z","updated_at":"2025-07-14T21:30:25.000Z","dependencies_parsed_at":"2025-05-31T03:18:05.506Z","dependency_job_id":"b0bc338d-e72b-4920-9806-274c747ac00c","html_url":"https://github.com/rlmartin/config-loader","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/rlmartin/config-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlmartin%2Fconfig-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlmartin%2Fconfig-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlmartin%2Fconfig-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlmartin%2Fconfig-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rlmartin","download_url":"https://codeload.github.com/rlmartin/config-loader/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlmartin%2Fconfig-loader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28862142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T22:56:21.783Z","status":"online","status_checked_at":"2026-01-29T02:00:06.714Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","typescript"],"created_at":"2025-12-25T00:55:16.926Z","updated_at":"2026-01-29T04:13:48.166Z","avatar_url":"https://github.com/rlmartin.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ConfigLoader\nUtility class/functions to help load config from various sources.\n\nInitial implementation narrowly supports AWS Lambda, but may be expanded to additional uses cases in the future.\n\n\n## Usage\nThe `ConfigLoader` class takes a type argument to strongly define the expected config variable names. Because the config can be loaded from multiple sources, there is no check of the existence of every variable _until is is attempted to be used_.\n\nTo use the loader, create a small file like this:\n\n```typescript\nimport { Context } from 'aws-lambda';\nimport { ConfigLoader } from '@rlmartin/config-loader';\n\nexport interface Config {\n  readonly FOO: string;\n  readonly BAR: string;\n}\n\nvar config: ConfigLoader\u003cConfig\u003e;\n\nexport async function loadConfig(context: Context) {\n  config = new ConfigLoader\u003cConfig\u003e(context);\n  await config.load();\n}\n\nexport function getConfig(key: keyof Config): Config[typeof key] {\n  return config.get(key);\n}\n```\n\nthen when config is needed:\n\n```typescript\nimport { Context, S3Event } from 'aws-lambda';\nimport { getConfig, loadConfig } from './config';\n\nexport async function handler(event: S3Event, context: Context): Promise\u003cvoid\u003e {\n  await loadConfig(context);\n  const foo = getConfig('FOO');\n  // ...\n}\n```\n\n\n## Supported config sources\nThe config is loaded from all of the following sources, in order of precedence (higher will override lower):\n\n1. Secrets Manager\n2. Environment variables (`process.env`)\n\n\n## Secret name\nThe secret name matches the AWS Lambda function name. This can be overridden by setting the `SECRET_NAME` environment variable, which should be set to _only_ the name of the secret (not the ARN).\n\n\n## Nested secrets\nIt is possible to load values from other secrets by setting the value to:\n\n```\n{\n  'propertyName': { '$ref':'secretName' }\n}\n```\n\nwhere `secretName` is the name of the secret that should be loaded as the value for `propertyName`. The value in the dependent secret can be any value (JSON or otherwise). This loading is recursive.\n\nBe careful to not load too many dependent secrets and/or nest too deeply - because a) SecretsManager pricing is based on the number of secrets loaded and b) it could adversely affect load times.\n\nThis same secret-loading process can be utilized by env vars, e.g.\n\n```\nprocess.env['propertyName'] = '{\"$ref\":\"secretName\"}';\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frlmartin%2Fconfig-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frlmartin%2Fconfig-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frlmartin%2Fconfig-loader/lists"}