0.2.0 • Published 2 years ago

@shaitan-masters/config v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Common Config

Install

npm i @shaitan-masters/config

or

yarn add @shaitan-masters/config


Usage
import {Config} from '@shaitan-masters/config';

export interface AppConfig {
	api: {
		apiUrl: string;
		authorization: {
			apikey: string;
		}
	};
	redis: {
		host: string;
		password: string;
		port: number;
		channels: {
			websockets: string
		}
	};
}

const configStruct = new Config('./config.js', (defineConfig) => ({
	api  : {
		apiUrl       : defineConfig<string>('API_URL', 'https://example.com'),
		authorization: {
			apikey: defineConfig<string>('apikey', '123456')
		}
	},
	redis: {
		host    : defineConfig<string>('REDIS_HOST', 'localhost'),
		password: defineConfig<string>('REDIS_PASSWORD', 'secret'),
		port    : defineConfig<number>('REDIS_PORT', 6379),
		channels: {
			websockets: defineConfig<string>('REDIS_CHANNELS_WEBSOCKETS', 'channel42')
		}
	}
}));

const config = configStruct.get();
console.log(config);

// {
// 	api: {
// 		apiUrl: 'https://example.com',
// 		authorization: { apikey: '123456' }
// 	},
// 	redis: {
// 		host: 'localhost',
// 		password: 'secret',
// 		port: 6379,
// 		channels: { websockets: 'channel42' }
// 	}
// }
0.2.0

2 years ago

0.1.0

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago