2.0.1 • Published 1 year ago

openapi-nodegen-config-helper v2.0.1

Weekly downloads
39
License
MIT
Repository
github
Last release
1 year ago

openapi-nodegen-config-helper

test

Used within the generate-it but easily used in other tools. Ensure environment variables are set or if not with a default value.

Return process variables to bool/number/object/string/undefined/null based on the value provided. See the index.js returnValue for more.

Available helpers

Method: withDefault

import ConfigHelper from 'openapi-nodegen-config-helper';
ConfigHelper.withDefault('SWAGGER_FILE', 'latest')

Method: required

import ConfigHelper from 'openapi-nodegen-config-helper';
ConfigHelper.required('JWT_SECRET')

withDefault adds a new process.env

Example

import dotenv from 'dotenv';
import ConfigHelper from 'openapi-nodegen-config-helper';
import someHelper from './helpers/someHelper';

dotenv.config();

export default {
  // Swagger file
  swaggerFile: ConfigHelper.withDefault('SWAGGER_FILE', 'latest'),
  jwtSecret: ConfigHelper.required('JWT_SECRET'),

  port: ConfigHelper.withDefault('PORT', 666),
  
  somethingElse: someHelper(process.env.CONFIG_HELPER_PORT), // CONFIG_HELPER_PORT is injected into the process.env and can be accessed this way 
  somethingOther: someHelper(process.env.CONFIG_HELPER_JWT_SECRET), // CONFIG_HELPER_JWT_SECRET is injected into the process.env and can be accessed this way 
}
2.0.1

1 year ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago