{"_id":"@buzo/jenv","name":"@buzo/jenv","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@buzo/jenv","version":"1.0.0","description":"JENV - JavaScript Environment Variables with built-in templating, filters, and resolvers","main":"src/index.js","type":"commonjs","license":"MIT","author":{"name":"Brytest","url":"https://github.com/Brytest"},"repository":{"type":"git","url":"git+https://github.com/Brytest/js-env.git"},"bugs":{"url":"https://github.com/Brytest/js-env/issues"},"homepage":"https://github.com/Brytest/js-env#readme","funding":{"type":"github","url":"https://github.com/sponsors/Brytest"},"keywords":["jenv","javascript","environment","dotenv","template","url-builder","environment-variables","api","templating","variables","config"],"engines":{"node":">=18"},"scripts":{"test":"node tests/run.js","test:security":"node tests/security.test.js","test:all":"npm run test && npm run test:security","validate":"node bin/jenv.js validate","prepublishOnly":"npm run test:all","release:patch":"npm version patch && git push && git push --tags && npm publish","release:minor":"npm version minor && git push && git push --tags && npm publish","release:major":"npm version major && git push && git push --tags && npm publish"},"bin":{"jenv":"bin/jenv.js"},"dependencies":{},"publishConfig":{"access":"public"},"gitHead":"1e7e62614b266c4fd1e97a6f67e9d47a008cbadb","_id":"@buzo/jenv@1.0.0","_nodeVersion":"26.4.0","_npmVersion":"12.0.1","dist":{"integrity":"sha512-bzMU/Jj1KJ+gZlAn0FshGm/TOH7hUSvtlPDf1fbOFVQiUBXM3IvoUPan9Q4B4zrug+G7X0xy+wW1JpKYeMIzaw==","shasum":"45352d389964ca04f160f989918b615149fdccd9","tarball":"https://registry.npmjs.org/@buzo/jenv/-/jenv-1.0.0.tgz","fileCount":25,"unpackedSize":74179,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBUl5MVmeHat/1VIS4AU1JXtO/t1OmJW6Ot5dO0RtgxDAiABIfBa7o+rHfRQaQk9065qzzfrOdsF6n2DmVwcLhkVnw=="}]},"_npmUser":{"name":"buzo","email":"ejimaduchibuzobright@gmail.com"},"directories":{},"maintainers":[{"name":"buzo","email":"ejimaduchibuzobright@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/jenv_1.0.0_1784741710575_0.323736929356762"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-22T17:35:10.362Z","1.0.0":"2026-07-22T17:35:10.762Z","modified":"2026-07-22T17:35:11.018Z"},"maintainers":[{"name":"buzo","email":"ejimaduchibuzobright@gmail.com"}],"description":"JENV - JavaScript Environment Variables with built-in templating, filters, and resolvers","homepage":"https://github.com/Brytest/js-env#readme","keywords":["jenv","javascript","environment","dotenv","template","url-builder","environment-variables","api","templating","variables","config"],"repository":{"type":"git","url":"git+https://github.com/Brytest/js-env.git"},"author":{"name":"Brytest","url":"https://github.com/Brytest"},"bugs":{"url":"https://github.com/Brytest/js-env/issues"},"license":"MIT","readme":"# endpoint-env\n\nCompile API endpoint URLs from environment variables, using parameters, filters, and dynamic expressions.\n\nDefine your endpoints as templated strings in `process.env`, then build real URLs from them at runtime — with type coercion, defaults, string transforms, and live values like dates, timestamps, and UUIDs baked right in.\n\n```bash\nnpm install endpoint-env\n```\n\nQuick Start\n\n```js\nconst endpoint = require('endpoint-env');\n\nprocess.env.ENDPOINT_MATCH = 'https://api.example.com/matches/{matchId}';\n\nconst url = endpoint.build('match', { matchId: 12345 });\n\nconsole.log(url);\n// https://api.example.com/matches/12345\n```\n\nEndpoints are read from environment variables prefixed with ENDPOINT_ by default. The part of the variable name after the prefix (lowercased) becomes the \"scope\" you pass to build().\n\nLoading a .env file\n\nendpoint-env uses the official dotenv package for loading .env files, with additional support for variable interpolation.\n\nPass env: true when constructing an instance to load the default .env file from your current working directory before anything else runs:\n\n```js\nconst { EndpointEnv } = require('endpoint-env');\n\nconst endpoint = new EndpointEnv({\n  env: true\n});\n\n// process.env is now populated from .env\n```\n\nYou can pass the same options dotenv.config() accepts:\n\n```js\nconst endpoint = new EndpointEnv({\n  env: {\n    path: '.env.production',\n    override: true,\n    debug: true\n  }\n});\n```\n\nA bare path string is shorthand for { path: ... }:\n\n```js\nconst endpoint = new EndpointEnv({\n  env: '.env.production'\n});\n```\n\nAnd you can load multiple files in one go by passing an array:\n\n```js\nconst endpoint = new EndpointEnv({\n  env: [{ path: '.env' }, { path: '.env.local' }]\n});\n```\n\nVariable Interpolation\n\nVariable interpolation is enabled by default, allowing you to reference other variables:\n\n```env\n# .env\nBASE_URL=https://api.example.com\nENDPOINT_USERS=${BASE_URL}/v1/users\nENDPOINT_MATCHES=${BASE_URL}/v1/matches/{matchId}\n```\n\nTo disable interpolation:\n\n```js\nconst endpoint = new EndpointEnv({\n  env: {\n    path: '.env',\n    interpolate: false\n  }\n});\n```\n\nStandalone dotenv usage\n\nIf you just want the loader itself, it's exported directly:\n\n```js\nconst { config } = require('endpoint-env');\n\nconfig();                        // loads ./.env\nconfig({ path: '.env.local' });  // loads a specific file\n```\n\nSecurity Features\n\nEndpoint-env includes a security manager to control access to sensitive data:\n\n```js\nconst endpoint = new EndpointEnv({\n  security: {\n    envAllowlist: ['API_KEY', 'BASE_URL'],  // Only allow these env vars\n    envDenylist: ['SECRET', 'PASSWORD'],    // Block specific env vars\n    maxDepth: 5,                            // Limit nested parameter depth\n    maxOutputSize: 1024 * 1024,             // Limit output size (1MB)\n    allowCrypto: true,                      // Use crypto for random numbers\n    safeMode: true                          // Disable dangerous resolvers\n  }\n});\n```\n\nParameters\n\nWrap a placeholder in curly braces and pass the value in at build time:\n\n```\nENDPOINT_MATCH=https://api.example.com/matches/{matchId}\n```\n\n```js\nendpoint.build('match', { matchId: 50 });\n// https://api.example.com/matches/50\n```\n\nDefault values\n\n```\n{page:1}\n```\n\nIf no value is passed for page, it falls back to 1.\n\nNested parameters\n\n```\n{team.slug}\n```\n\n```js\nendpoint.build('team', { team: { slug: 'man-utd' } });\n// resolves team.slug from the nested object\n```\n\nFilters\n\nChain one or more filters onto a parameter with |:\n\n```\n{name|trim|lowercase}\n{title|slug}\n{name|replace(_, )}\n{title|truncate(20)}\n{path|prepend(/api/)}\n{file|append(.json)}\n```\n\nBuilt-in filters\n\nFilter Description\nlowercase Convert to lowercase\nuppercase Convert to uppercase\ntrim Trim whitespace\ncapitalize Capitalize first letter\nslug Generate a URL-safe slug\ncamel camelCase\nsnake snake_case\nkebab kebab-case\nreplace Replace text\nprepend Prefix a value\nappend Suffix a value\ndefault Fallback when a value is empty\ntruncate Limit string length\npadStart String.padStart\npadEnd String.padEnd\nslice Slice a string\nrepeat Repeat a string\nurlencode URL-encode a value\nurldecode URL-decode a value\nnumber Coerce to a number, optionally fixed\nboolean Coerce truthy strings to a boolean\nsplit Split a string into an array\njoin Join an array into a string\nfirst First element of an array\nlast Last element of an array\nreverse Reverse a string or array\n\nExpressions\n\nUse ${...} for dynamic, parameter-free values:\n\n```\n${date}\n${date(+5)}\n${date(-2m)}\n${timestamp}\n${uuid}\n${random(1,100)}\n${env(API_KEY)}\n${hostname}\n${platform}\n${arch}\n${year}\n${month}\n${day}\n${quarter}\n${weekday}\n${time}\n${datetime}\n```\n\nThere's also a shorthand for pulling in another environment variable directly:\n\n```\n$HOST\n$HOST:fallback.example.com\n```\n\nBoth $ENV shorthand and ${env(...)} are inserted as-is, without URL-encoding, since they're typically trusted values like a hostname.\n\nRegistering your own filters and resolvers\n\n```js\nendpoint.registerFilter('shout', value => String(value).toUpperCase() + '!');\n```\n\n```\n{value|shout}\n```\n\n```js\nendpoint.registerResolver('season', () => '2026-2027');\n```\n\n```\n${season}\n```\n\nBoth can be async — use endpoint.buildAsync() instead of endpoint.build() when any registered filter or resolver returns a promise.\n\nPlugins\n\nBundle related filters/resolvers together and install them as a unit:\n\n```js\nendpoint.use(env => {\n  env.registerFilter('hello', value => 'Hello ' + value);\n});\n```\n\nTwo plugins ship with the package:\n\n```js\nconst endpoint = require('endpoint-env');\n\nendpoint.use(endpoint.builtinPlugins.date);   // adds ${isoDate}, ${unix}\nendpoint.use(endpoint.builtinPlugins.debug);  // adds ${debug}, |json, |length\n```\n\nDiscovering and validating endpoints\n\n```js\nendpoint.list();        // ['match', 'fixtures', 'search', ...]\nendpoint.has('match');  // true\n\nendpoint.validate('match');  // true, or an error message\nendpoint.validateAll();      // { match: true, fixtures: true, ... }\n\nendpoint.preload();          // compiles every configured endpoint up front\n```\n\nValidation and build errors point directly at the problem in the template:\n\n```\nUnknown filter 'nope' on parameter 'name'.\n\nhttps://api.com/{name|nope}\n                ^^^^^^^^^^^\n```\n\nCaching, freezing, and encoding\n\n```js\nendpoint.clearCache();\nendpoint.stats();\n```\n\n```js\nendpoint.freeze(); // prevents any further registerFilter/registerResolver/use calls\n```\n\n```js\nconst { create } = require('endpoint-env');\n\n// Disable URL-encoding entirely\nconst raw = create({ encode: false });\n\n// Or supply your own encoder\nconst custom = create({\n  encode(value) {\n    return value;\n  }\n});\n```\n\nMultiple instances\n\nThe default export is a ready-to-use singleton. For isolated configuration (a different prefix, cache size, or encoder), create your own instance:\n\n```js\nconst { create } = require('endpoint-env');\n\nconst endpoint = create({\n  prefix: 'MYAPP_',\n  cacheSize: 50\n});\n```\n\nErrors\n\nAll errors share a common base class and carry structured details:\n\n```js\nconst { errors } = require('endpoint-env');\n\ntry {\n  endpoint.build('match');\n} catch (err) {\n  if (err instanceof errors.MissingParameterError) {\n    // handle missing parameter\n  }\n}\n```\n\nAvailable error types: EndpointEnvError, ParserError, ValidationError, MissingParameterError, FilterError, ResolverError, ConfigurationError, PluginError, LimitError.\n\nCLI\n\n```bash\nendpoint-env list\nendpoint-env validate\nendpoint-env preload\nendpoint-env stats\nendpoint-env build match '{\"matchId\":12345}'\n```\n\nAPI reference\n\n```\nbuild(scope, params?, context?)       Build a URL synchronously\nbuildAsync(scope, params?, context?)  Build a URL, awaiting async filters/resolvers\ncompile(scope)                        Parse and validate a template, returning its tokens\nhas(scope)                            Check whether a scope is configured\nlist()                                List all configured scope names\nvalidate(scope)                       Validate a single scope\nvalidateAll()                         Validate every configured scope\npreload()                             Compile every configured scope up front\nclearCache()                          Clear the compiled-template cache\nstats()                               Inspect filters, resolvers, plugins, and cache state\nfreeze()                              Lock the instance against further registration\nregisterFilter(name, handler)\nunregisterFilter(name)\nregisterResolver(name, handler)\nunregisterResolver(name)\nuse(plugin)                           Install a plugin function\nremovePlugin(name)\nconfig(options?)                      Load a .env file into process.env (standalone, like dotenv)\nparse(source)                         Parse a .env-formatted string into an object\ninterpolate(value, env?)              Interpolate variables in a string\n```\n\n## License\n\nMIT © [Brytest](https://github.com/Brytest)\n\nSee the [LICENSE](./LICENSE) file for details.\n\nMIT License\n\nCopyright (c) 2026 Brytest\n\nPermission is hereby granted...","readmeFilename":"README.md","_rev":"1-f2c6d43dd71241207aa0426042d496f4"}