Skip to content

App configuration #5

@tur-nr

Description

@tur-nr

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"
  ]
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions