Socket
Socket
Sign inDemoInstall

@oerlikon/config

Package Overview
Dependencies
84
Maintainers
7
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @oerlikon/config

Easily add server and client configuration to your oerlikon app. This package will provide server and client config that can be changed at runtime with environment variables.


Version published
Maintainers
7
Created

Readme

Source

@oerlikon/config

Easily add server and client configuration to your oerlikon app. This package will provide server and client config that can be changed at runtime with environment variables.

If you use typescript, you will get typings based on your configuration.

Only the configuration under client will be accessibly on the frontend so your secrets stay secret.

Installation

  1. Install the npm package: npm install @oerlikon/config

  2. Create a JSON config file at ./config/default.json, e.g.

    {
      "serverSecret": "your-secret",
      "client": {
        "apiUrl": "your-url"
      }
    }
    

    This is your default configuration for your app

  3. Add the middleware to your express server:

    import configMiddleware from '@oerlikon/config/middleware';
    
    ...
    
    app.use(configMiddleware);
    
  4. only applies if you use typescript: add typescript include directory: in ./tsconfig.json, add 'config' to include in ./client/tsconfig.json, add '../config' to include

Usage

On the server:

import config from '@oerlikon/config';

console.log(config.serverSecret);

On the client:

import config from '@oerlikon/config/client';

console.log(config.apiUrl);

Advanced usage

set context config

You can place additional config files next to your default.json file:

  • development.json: Config used in development
  • production.json: Config used in production
  • test.json: Config used in testing

All config files will extend the default.json.

overwrite config with environment variables

Place a configuration file name custom-environment-variables.json next to your default.json. It should have the same structure as your other configuration files, but instead of providing values, you provide a mapping between environment variables and your config:

{
  "serverSecret": "SERVER_SECRET",
  "client": {
    "apiUrl": "API_URL"
  }
}

FAQs

Last updated on 13 Feb 2020

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc