Skip to content
This repository was archived by the owner on May 19, 2020. It is now read-only.

Commit 1de5a45

Browse files
committed
Initial commit
1 parent e17505a commit 1de5a45

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+59782
-0
lines changed

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#root = true
2+
3+
[*]
4+
indent_style = space
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
max_line_length = 100
10+
indent_size = 2
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
node_modules
2+
coverage
3+
.nyc_output
4+
.DS_Store
5+
*.log
6+
.vscode
7+
.idea
8+
compiled
9+
.awcache
10+
.rpt2_cache
11+
docs

.travis.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: node_js
2+
cache:
3+
directories:
4+
- ~/.npm
5+
notifications:
6+
email: false
7+
node_js:
8+
- '10'
9+
- '11'
10+
- '8'
11+
- '6'
12+
script:
13+
- npm run test:prod && npm run build
14+
after_success:
15+
- npm run travis-deploy-once "npm run report-coverage"
16+
branches:
17+
except:
18+
- /^v\d+\.\d+\.\d+$/

README.md

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
Javascript microservice configuration module
2+
--------------------------------------------
3+
4+
Configuration module for microservices written on TypeScript. Specially created
5+
for follow up corporate standards of application configuration.
6+
7+
## Installation
8+
9+
```bash
10+
npm install --save configuration-js
11+
12+
yarn add configuration-js
13+
```
14+
15+
## Usage
16+
17+
By default path to configuration directory and application stage
18+
loading from `/app/configuration` with `local` stage.
19+
20+
1) Simple
21+
```ts
22+
import Configuration from 'configuration-js';
23+
24+
const conf = new Configuration();
25+
conf.load();
26+
27+
console.log(conf.all()); // get all config
28+
console.log(conf.get('foo.bar')); // get nested key use dot notation
29+
```
30+
31+
2) If u would like override default values, you can pass 2 arguments to
32+
class constructor or set up use setters.
33+
34+
```php
35+
import Configuration from 'configuration-js';
36+
37+
const conf = new Configuration('./configuration', 'test');
38+
conf.load();
39+
40+
conf.get('foo'); // full example on the top
41+
```
42+
43+
3) If the operating system has an env variables `CONFIG_PATH` and `STAGE`,
44+
then values for the package will be taken from there.
45+
46+
```bash
47+
export CONFIG_PATH=/configuration
48+
export STAGE=prod
49+
```
50+
51+
```php
52+
import Configuration from 'configuration-js';
53+
54+
const conf = new Configuration('./configuration', 'test');
55+
conf.load(); // loaded files from /configuration for prod stage.
56+
57+
conf.get('foo'); // full example on the top
58+
```
59+
60+
4) If u want to see logs and see how load process working,
61+
pass you logger to property:
62+
63+
First, install logger (winston supported bu default):
64+
```bash
65+
npm install --save winston
66+
67+
yarn add winston
68+
```
69+
70+
Second, pass you logger to property like this:
71+
```ts
72+
import Configuration from 'configuration-js';
73+
import WinstonConsoleLogger from 'configuration-js/winston-console-logger';
74+
75+
const conf = new Configuration();
76+
conf.logger = new WinstonConsoleLogger(winston.createLogger({
77+
transports: [new winston.transports.Console()]
78+
}));
79+
80+
conf.load();
81+
82+
conf.get('foo'); // full example on the top
83+
```
84+
85+
Also, your can pass any logger who implements library `LoggerInterface`.
86+
87+
## License
88+
89+
The MIT License
90+
91+
Copyright © 2019 teamc.io, Inc. https://teamc.io
92+
93+
Permission is hereby granted, free of charge, to any person obtaining a copy
94+
of this software and associated documentation files (the "Software"), to deal
95+
in the Software without restriction, including without limitation the rights
96+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
97+
copies of the Software, and to permit persons to whom the Software is
98+
furnished to do so, subject to the following conditions:
99+
100+
The above copyright notice and this permission notice shall be included in
101+
all copies or substantial portions of the Software.
102+
103+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
104+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
105+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
106+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
107+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
108+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
109+
THE SOFTWARE.

code-of-conduct.md

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
nationality, personal appearance, race, religion, or sexual identity and
10+
orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [email protected]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at [http://contributor-covenant.org/version/1/4][version]
72+
73+
[homepage]: http://contributor-covenant.org
74+
[version]: http://contributor-covenant.org/version/1/4/

0 commit comments

Comments
 (0)