npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ibm-gpn/platform-config

v1.1.39

Published

Library with shared configuration

Downloads

3

Readme

GPN shared configuration library

Configuration could be performed by creation of the environment specific configuration files with specific app configuration in it or/and by defining environment variables.

Getting started

Login to the private artifactory (ask maintainers for credentials):

npm login

Install dependencies:

npm i

To turn on debug messages display set NODE_DEBUG=gpn-config* environment variable in your project.

When developing, it's useful to use npm's link feature to link local copy of the library to your project.

In gpn-config library: npm run relink

In your project: npm link @ibm-gpn/gpn-config

Add new configs

To add new app specific configurations you need to add it to the environment specific config file in the /configs folder or to the /configs/default.ts. Your config must be placed under application name key and should consist props that later will be merged with default ones.

Ex.:


{
    ...
    APP_NAME: {
        db: {
            database: 'APP_SPECIFIC_DB'
        },
        server: {
            port: 8888 // APP specific port
        }
    }
}

Usage

Instantiate in your project with application name from EApplication enum:

import { EApplication } from '@ibm-gpn/gpn-common';

const config = new Configuration(EApplication.DP);

// Get database configuration for DP app.
console.log('DB configuration', config.db());

// Get api configuration for DP app.
console.log('API configuration', config.api());

// Get specific key from configuration.
console.log('DB SSL option', config.instance.get('db.ssl'));

Also, you can get configuration of specific app by passing app name from the EApplication enum:

import { EApplication } from '@ibm-gpn/gpn-common';

const config = new Configuration(EApplication.DP);

// Get database configuration for DP app.
console.log('DB configuration', config.db());

// Get api configuration for DP app.
console.log('API configuration', config.api());

// Get specific key from configuration.
console.log('DB SSL option', config.instance.get('db.ssl'));

Under the hood, node-config library used, so you can use its api throw instance property:

import { EApplication } from '@ibm-gpn/gpn-common';

const config = new Configuration(EApplication.DP);

// Get specific key from configuration.
console.log('DB SSL option', config.instance.get('db.ssl'));

// Get specific key existence in configuration.
console.log('Is DB SSL option exists?', config.instance.has('db.ssl'));

You can pass specific configuration and it will be used with highest priority:

import { EApplication } from '@ibm-gpn/gpn-common';

const config = new Configuration(EApplication.DP, { db: { username: 'master' } });

console.log('DB SSL option', config.instance.get('db.username'));
// master

NestJS module

This library provides you with global NestJS configuration module, so you can load it once in your NestJS app and use it everywhere within your app.


import { EApplication } from '@ibm-gpn/gpn-common';

...

@Module({
    imports: [ConfigModule.register(EApplication.SECURITY)],
})
export class AppModule { }

Then you can use app specific ConfigService in your code.


@Module({
    imports: [
        JwtModule.registerAsync(
            {
                inject: [ConfigService],
                useFactory: (config: ConfigService) => config.auth(),
            }),
    ],
})
export class AuthModule {}

Also, you can use decorator to inject ConfigService into your class.


@Injectable()
export class SomeService {
    constructor(@InjectConfig() private readonly config: ConfigService) {
    }
}

Environment variables

Also, you can define env variables listed below (higher priority) with app prefix. For example, to define database name for the SECURITY app, you need to pass SECURITY_DB_NAME env variable.

Database:

DB_NAME         -   Name.
DB_HOST         -   Host. Default: localhost.
DB_PASSWORD     -   Password. Default: 1qazse4rfv.
DB_PORT         -   Port. Default: 30933.
DB_SCHEMA       -   Schema. Default: dev.
DB_USER         -   User. Default: admin.

Host:

HOST                          -   host url.

Server:

HTTP_PORT                        -   Server port.

Microservice:

MS_PORT                          -   Microservice port.

Authentication and authorization:

AUTH_SECRET                     -   Secret key. Default: 2c54a418-3563-4af9-849b-36b6ff6a5429.
AUTH_TOKEN_EXPIRATION_TIME      -   Authentication token expiration time. Default: 1h.

API:

API_PREFIX      -   Api prefix.

Swagger:

SWAGGER_PREFIX      -   Swagger portal prefix. Default: api-doc.

Logger:

LOGGER_LEVEL        -   Level of logging.    
LOGGER_NAME         -   Logger name.    

CAPEX:

CAPEX_BASE_URL      -   Capex base url.

Primavera:

PRIMAVERA_HOST      -   Primavera host.
PRIMAVERA_PORT      -   Primavera port.

Deployment

NPM registry

To publish library you should be member of the ibm-gpn organization in NPM. If you are not - contact with organization admins.

List of the team admins:

New version tag

Run one of the following commands: npm run release-patch - to increment and push patch version npm run release-minor - to increment and push minor version npm run release-major - to increment and push major version

After it, new git tag will be pushed to the master branch.

Publish

For publishing to the private NPM registry you need to login:

npm login --registry=https://ibm-platform-repo.club/repository/npm-private/

After that run:

npm publish