Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@hapiness/config
Advanced tools
Readme
Configuration module based on node-config & js-yaml libraries.
yarn
or npm
it in your package.json
$ npm install --save @h@hapiness/config
or
$ yarn add @hapiness/config
"dependencies": {
"@hapiness/config": "^1.2.1",
//...
}
//...
./config/default.yml
:
my:
config: test
Node.js Script
:
import { Config } from '@hapiness/config';
if (Config.has('my.config')) {
console.log(Config.get('my.config')); // output: 'test'
}
./config/default.yml
:
external_service:
baseUrl: 'test'
mymodule_database:
provider: postgresql
hostname: localhost
user: pguser
password: keyboard cat
Hapiness module
:
// external-module.ts
import {
HapinessModule,
CoreModuleWithProviders,
InjectionToken,
Inject,
Optional,
} from '@hapiness/core';
import { ConfigHelper, ConfigInterface } from '@hapiness/config';
@HapinessModule({
...
})
export class ExternalModule {
static setConfig(config: ConfigInterface): CoreModuleWithProviders {
return {
module: ExternalModule,
providers: [ConfigHelpers.getProvider('mymodule_database', config)]
};
}
}
export class Service {
constructor(@Optional() @Inject(ConfigHelper.getInjectionToken('mymodule_database')) config) { // @Optional to not throw errors if config is not passed
...
}
}
// main-module.ts
import {
HapinessModule,
} from '@hapiness/core';
import { ExternalModule } from 'external-module';
import { Config } from '@hapiness/config';
@HapinessModule({
...
imports: [ ExternalModule.setConfig(Config.get('mymodule_database')) ]
})
...
Hapiness service
:
// main-module.ts
import {
HapinessModule,
} from '@hapiness/core';
import { ConfigHelper, Config } from '@hapiness/config';
import { MyCustomService } from './services';
@HapinessModule({
...
providers: [
ConfigHelper.getProvider('external_service'),
MyCustomService,
...
]
})
...
import { Injectable } from '@hapiness/core';
import { ConfigInterface } from '@hapiness/config';
// my-custom-service.ts
@Injectable()
class MyCustomService {
private _baseUrl: string;
constrcutor(
@Inject(ConfigHelper.getInjectionToken('external_service'))
private _config: ConfigInterface
) {}
connect() {
this._baseUrl = this._config.get<string>('baseUrl');
}
}
...
get()
was a falsy value and wrongly interpreted as undefinedpeerDependencies
config
Config
module.Julien Fauville | Antoine Gomez | Sébastien Ritz | Nicolas Jessel |
Copyright (c) 2018 Hapiness Licensed under the MIT license.
FAQs
Configuration Library to use it inside Hapiness framework
The npm package @hapiness/config receives a total of 12 weekly downloads. As such, @hapiness/config popularity was classified as not popular.
We found that @hapiness/config demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.