Configuration: config.yml - reactor-X/kyrin-express GitHub Wiki

This file is found as config-dev.yml/config-prod.yml in the config directory. The container is initialised using the relevant node environment's configuration file. Configurations for logger,connections, application name and static path bindings are specified here.

Structure

The file contains two keys, application and middlewares.

Note that the feature of loading express middlewares is still in alpha. You can always contribute code and report bugs in the behaviour.

config.yml

application:
middlewares:

Application section includes the following options for configuration.

name

You can give your application name here, this will be reflected in the system logs generated by the application. If no name is specified, this field defaults to "kyrin".

config.yml

application:
    name: kyrin

path_bindings

You can specify static paths on your server. These can be web resources directories for say stylesheets and javascript files. Note that these paths are relative to kyrin root directory and the indexes are indicative only. Actual binding occurs depending upon the path specified as [alias-for-path,relative-path-from-kyrin-root] .

config.yml

application:
    path_bindings:
            binaries: ['/lib','node_modules']
            styles: ['/css','public/assets/css']
            javascripts: ['/js','public/assets/js']

connections

You can specify network connections here, a connection can be a simple connection to a host over a port or a database connection. (Currently only mongodb is supported). Kyrin uses mongoose to provide database connectivity to the application.

Migration configuration is automatically generated for a connection when a model from that connection is loaded. Migration configurations are stored in migrations directory separately for each new connection.

config.yml

application:
     connections:
        logstash:
            host: localhost
            port: 5000
        mongodb:
            type: mongo   #Defines the connection as a mongodb connection.
            host: localhost
            port: 27017  #optional
            database: test 
            username:you #optional
            password:yourpassword #optional

logger

Kyrin achieves logging through bunyan middleware. Logs are written to var/log/environment/app.log for application and to var/log/environment/network.log by default. You can override this behavior by specifying logging mode here.

File and TCP modes are supported currently. TCP host should be specified in connections. The specified connection can then be used to send logs over TCP. Path is absolute in case of file mode.

config.yml

application:
    logger:
        mode: file
        path: /var/log/myapp #Path to directory.

                          OR
    logger:
        mode: tcp
        connection: logstash

default_log_level

Supported values : trace,debug,info,warn,error,fatal Here you can specify the default log level for the application. Any log message having a priority/level equal or higher than specified default will be written to logs. Defaults to info.

config.yml

application:
    default_log_level: info

Middlewares section has the following options (Limited support/alpha)

You can specify middleware name (node module name) along with the set of initialization parameters. Currently, the application simply evaluates use_default. If true, it attaches an instance of middleware created using no arguments to constructor. In case of use_default being false, it passes the init_params object to the middleware's constructor.

config.yml

middlewares:
    helmet:
        use_default: true
    
    express-session:
        init_params:
            secret: i!gP&3ibF}Qx<)+V(ZiY$&nXY)R&AUj@dQEz47M?<FU[&21jtL[GQ.Kzm-.n%=C
            resave: true
            saveUninitialized: true
        use_default: false