Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App configuration #5

Open
tur-nr opened this issue Jul 3, 2020 · 0 comments
Open

App configuration #5

tur-nr opened this issue Jul 3, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@tur-nr
Copy link
Contributor

tur-nr commented Jul 3, 2020

Serva currently accepts 4 configuration values to create an App instance. These options should be able to be overwritten by flags, environment variables, config, and defaults (in that order).

interface ServaConfig {
  port: number;
  hostname?: string;
  extension: string;
  methods: string[];
}

1.Flags

$ serva start \
   --port 4500 \
   --hostname localhost \
   --extension ".ts" \
   --methods get,post,put,delete,patch

2. Environment

# Port
SERVA_PORT=4500

# Host (ordered in priority)
SERVA_HOSTNAME=localhost
SERVA_HOST=localhost

# Extension (ordered in priority)
SERVA_EXTENSION=".ts"
SERVA_EXT=".ts"

# Methods
SERVA_METHODS="get,post,put,delete,patch"

3. Config file

{
  "port": 4500,
  "hostname": "localhost",
  "extension": ".ts",
  "methods": [
    "get",
    "post",
    "put",
    "delete",
    "patch"
  ]
}

4. Defaults

const DEFAULT_CONFIG = {
  port: 4500,
  extension: ".ts",
  methods: [
    "get",
    "post",
    "put",
    "delete",
    "patch"
  ]
};
@tur-nr tur-nr added the enhancement New feature or request label Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant