@codrjs/config
v1.0.7
Published
Codr configuration, unified
Downloads
3
Readme
@codrjs/config
Purpose
This repository is a custom-built configuration manager for all repositories. This module manages everything configuration and should be used in all projects manages so that environment variables are unified, making transitioning development from one domain to another easy.
Getting started
Install the package from the npm registry.
yarn add @codrjs/config
Import the config package and use the variables you need!
*Please note: This package assumes you have defined the environment variables you are accessing and does no error checking.*
/* Import the config package */
import config, { ExpressConfig } from "@codrjs/config";
import { express } from "express";
const app = express();
app.listen(config.express.port, config.express.host, () => {
console.log(
`Server is starting on ${ExpressConfig.host}:${ExpressConfig.port}`,
);
});
Environemnt Variable Names
Location of environment variable is postfixed to Config.{location}
(e.g. Config.express.host
).
| Env var | Location | Description |
| --------------------------- | ------------------------------- | --------------------------------------------------------------------------------------- |
| ENV
| env
| Deployment envionment - dev
, qa
, stage
, prod
|
| HOSTNAME
| hostname
| Deployment docker hostname |
| Provided via npm | name
| Deployment service name - example: codr-user-user |
| Provided via npm | version
| Deployment version - example: 1.0.0
|
| AWS_REGION
| aws.region
| AWS - deployment region |
| AWS_SES_API_VERSION
| aws.ses.api.version
| AWS SES - api version |
| AWS_SES_ACCESS_KEY
| aws.ses.access.key
| AWS SES - IAM access key id |
| AWS_SES_ACCESS_SECRET
| aws.ses.access.secret
| AWS SES - IAM access key secret |
| CODR_USER_AUTH_SVC_URL
| codr.svc.user.auth
| Codr - user authentication service |
| CODR_USER_PROFILE_SVC_URL
| codr.svc.user.profile
| Codr - user profile entity service |
| CODR_USER_SESSION_SVC_URL
| codr.svc.user.session
| Codr - user session entity service |
| CODR_USER_USER_SVC_URL
| codr.svc.user.user
| Codr - user entity service |
| EMAIL_FROM
| email.from
| Email - from address |
| EMAIL_REPLY_TO
| email.replyto
| Email - reply to address(es) |
| EXPRESS_HOST
| express.host
| Express server - listener host |
| EXPRESS_PORT
| express.port
| Express server - listener port |
| GIT_BRANCH
| git.brach
| Git - branch |
| GIT_COMMIT
| git.commit
| Git - commit sha |
| GIT_REPO
| git.repo
| Git - repository |
| JWT_ALGORITHM
| jwt.algorithm
| JWT - algorithm, default HS256
|
| JWT_SECRET
| jwt.secret
| JWT - secret, key to decode jwt, must be the same across all services in an environment |
| JWT_ISSUER
| jwt.issuer
| JWT - issuer, default codrjs.com
|
| KAFKA_BROKERS
| kafka.brokers
| Kafka server - comma seperated locations of the kafka brokers |
| KAFKA_CLIENT_ID
| kafka.clientId
| Kafka server - name of the kafka cluster |
| KAFKA_CONSUMER_GROUP
| kafka.consumer.group
| Kafka server - consumer group |
| MONGO_URI
| mongo.uri
| MongoDB - server URL, please include username and password to this string |
| NODE_ENV
| node.env
| Node environment - development
, production
, testing
|
| Provided via npm | node.verison
| Node version - example: 16.19.1
|
| Provided via npm | node.modules
| Node modules - string array of all dependencies |
| Provided via yarn | node.yarnVersion
| Node - package manager version |
| OPENAPI_INFO_TITLE
| openapi.info.title
| OpenAPI - documentation title |
| OPENAPI_INFO_DESC
| openapi.info.description
| OpenAPI - documentation description |
| OPENAPI_SERVER_ONE_URL
| openapi.server[0].url
| OpenAPI - server one url |
| OPENAPI_SERVER_ONE_DESC
| openapi.server[0].description
| OpenAPI - server one description |
| OPENAPI_SERVER_TWO_URL
| openapi.server[1].url
| OpenAPI - server two url |
| OPENAPI_SERVER_TWO_DESC
| openapi.server[1].description
| OpenAPI - server two description |
| OPENAPI_SERVER_THREE_URL
| openapi.server[2].url
| OpenAPI - server three url |
| OPENAPI_SERVER_THREE_DESC
| openapi.server[2].description
| OpenAPI - server three description |
| OPENAPI_SERVER_FOUR_URL
| openapi.server[3].url
| OpenAPI - server four url |
| OPENAPI_SERVER_FOUR_DESC
| openapi.server[3].description
| OpenAPI - server four description |
| OPENAPI_SERVER_FIVE_URL
| openapi.server[4].url
| OpenAPI - server five url |
| OPENAPI_SERVER_FIVE_DESC
| openapi.server[4].description
| OpenAPI - server five description |
TODO
- [ ] ...
Contributing
# Clone the repo
git clone [email protected]:CodrJS/config.git
# Install yarn if you don't have it already
npm install -g yarn
# Install dependencies, build, and test the code
yarn install
yarn build
yarn test