Do you like configuring stuff? - of course no!
Do you like changing the stuff you configured? - Hell no!
Do you like playing detective and understand which value belong to what environment? - maybe...
Kevin provides a unified framework gto handle the configuration for all the environments at one place.
Do you need another environment? No problem, with Kevin you can create a configuration for your specific environment in few clicks. And ... as abonus, you can inherit all configuration parameters of a different environment and chnage only the parameters you need!.
- Install Kevin core:
npm i @kevin-infra/core
- Connect to a repository
Kevin use a
Repository
in order to store the configuration informations, and aProvider
for communication with the repository. To connect Kevin to a certain repository, simply create a provider, and provide it while initialiingKevinService
:
import Redis from 'ioredis';
import { RedisProvider } from '@kevin-infra/redis';
import { KevinService } from '@kevin-infra/core/services';
const provider = new RedisProvider( new Redis(
'redis://localhost:6379'
));
const kevinService = new KevinService(provider);
Environment is a collection of keys used by a certain deploymnet (Dev, Prod, QA, Staging etc').
Environments are managed in Kevin in a tree stracture, for example:
-Root
-- Prod
-- Dev
--- Staging
--- QA
In the above example:
Prod
andDev
will inherit all the keys of theRoot
environmentStaging
andQA
will inhterit all the keys of theDev
environment.
Each environment can override the values of the parent environment and provide a unique value for the environment.
First we need to initialize the root environment:
const rootEnviroment = await createRootEnvironment();
The rootEnvironment
contains the information of the created environment:
- name: The name of the environment.
- id: the id of the enviroment:
- parentEnviroment: Information about the parent env (null for the root environment).
To create a sun environment under root
(or any other environment), run the following code:
const newEnvironmentInfo = await this.kevinService.createEnvironment(
"my-new-env-name",
PARENT_ENVIRONMENT_ID
);
await kevinService.setCurrentEnvironment(ENVIRONMENT_ID) // Setting kevin to work against specific environment.
const kevinKeys: Array<IKevinValue> = await kevinService.getEnvironmentData();
await kevinService.setCurrentEnvironment(ENVIRONMENT_ID) // Setting kevin to work against specific environment.
const value: IKevinValue = await kevinService.getValue("my-key");
await kevinService.setCurrentEnvironment(ENVIRONMENT_ID) // Setting kevin to work against specific environment.
const value: IKevinValue = await kevinService.setValue("my-key", "my-value");
await kevinService.setCurrentEnvironment(ENVIRONMENT_ID) // Setting kevin to work against specific environment.
const value: IKevinValue = await kevinService.addKey("my-key", "my-value", "default-value");
The default-value
is an optional default value that can be passed in order to set a value at the root environment.
If no value was provided, the key in the root environment will be set with an empty string.
Instead of taking the source code of the server and client and publish the website on your own, you can use the up to date docker image to do so.
How do you do that?
- Create a new Dockerfile.
- Copy & Paste the following template:
FROM tkul6/kevin-redis-provider:latest
ENV PROVIDER_TYPE '<PROVIDER_TYPE>'
EXPOSE 3000
CMD ["node", "kevin.server/dist/index.js"]
- Select the desired provider type (supported providers are listed below).
- Add additional
ENV
params specific to the provider you selected. - Create the image and use it!
Provider | Env value | Additional Parameters |
---|---|---|
Redis | provider.type.redis |
REDIS_PROVIDER_URL - The url to the reids server (ENV param |
For Kevin server with Redis provider initialized that points to redis://my-reids-server:6389
The docker file should look like this:
FROM tkul6/kevin-redis-provider:latest
ENV PROVIDER_TYPE 'provider.type.redis'
ENV REDIS_PROVIDER_URL 'redis://my-reids-server:6389'
EXPOSE 3000
CMD ["node", "kevin.server/dist/index.js"]
- Providers.
- Kevin Website.