Giter Site home page Giter Site logo

enviper's Introduction

Here is a list of my own open source projects:

NestJS

nestjs-pino

GitHub stars npm

Platform agnostic logger for NestJS based on pino with request context in every log.


nestjs-session

GitHub stars npm

Idiomatic session module for NestJS. Built on top of express-session.


nestjs-cookie-session

GitHub stars npm

Idiomatic cookie session module for NestJS. Built on top of cookie-session.


nestjs-roles

GitHub stars npm

Type safe roles guard and decorator made easy.


nestjs-injectable

GitHub stars npm

@Injectable() on steroids that simplifies work with inversion of control in your hexagonal architecture.


nest-ratelimiter

GitHub stars npm

Distributed consistent flexible NestJS rate limiter based on Redis.


create-nestjs-middleware-module

GitHub stars npm

Create a simple idiomatic NestJS module based on Express/Fastify middleware in just a few lines of code with routing out of the box.


nestjs-configure-after

GitHub stars npm

Declarative configuration of NestJS middleware order.


nestjs-saga

GitHub stars npm

Basic implementation of saga pattern for NestJS (do not confuse it with the built-in sagas).


nestjs-gcp-pubsub

GitHub stars npm

The most basic and unopinionated implementation of GCP PubSub transport for NestJS microservices.


nest-nsq-transport

GitHub stars npm

The most basic and unopinionated implementation of NSQ transport for NestJS microservices.

React Native

react-native-launch-arguments

GitHub stars npm

Get launch arguments for testing with Detox and Appium.

Go

enviper

GitHub stars

Consider environment variables while unmarshaling viper's config.


rebus

GitHub stars

Type-safe bus generator for go.


ratelimiter

GitHub stars

Rate limiter with sliding window algorithm implementation.

enviper's People

Contributors

celian-garcia avatar d-enk avatar garenchan avatar iamolegga avatar jpughcs avatar leventov avatar ollevche avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

enviper's Issues

Pointers not being mapped correctly with only ENV variables

Hi,

First thanks for the contribution.
I'm checking this package becase I've experienced the issue with viper, however seems like the example you provide in the documentation does not work as expected when there's no configuration file that fills values for pointers and maps.

If I execute the example without any config file (just adding environment values) the value for Barries map[string]barry and Quxxy *quxxy is allways nil. I have pushed some code in a personal repo to illustrate this issue: https://github.com/afdecastro879/enviper-test If you run the main program you will find that I'm setting the environment variables like this:

	os.Setenv("FOO", "foo")
	os.Setenv("BARRY_BAR", "42")
	os.Setenv("BAZ", "true")
	os.Setenv("BARRIES_KEY1_BAR", "42")
	os.Setenv("QUXXY_QUX", "ipsum")

But when printing the struct the result for the values explained above are nil:

main.config{Foo:"foo", Barry:main.barry{Bar:42}, Barries:map[string]main.barry(nil), Bazzy:main.bazzy{Baz:true}, Quxxy:(*main.quxxy)(nil)}

Enable support for maps with as value primitive types

Currently, only maps with as value a struct are supported.
If you try using the following map it will crash:
map[string]string

To make this function you need to use a map[string]struct{ Value string }.

Example to reproduce the issue

e := enviper.New(viper.New())
e.AddConfigPath(".")
e.SetConfigName("config")

var cfg struct {
    Fields map[string]string
}

if err := e.Unmarshal(cfg); err != nil {
    panic("unable to decode into config struct")
}
[Fields]
key1="value1"

e.VIper.ReadInConfig run as part of Unmarshal clears merged in fields

Hi,

due to e.Viper.ReadInConfig() that is invoked as part of Enviper#Unmarshal any additional fields added via Viper#MergeConfigMap method are cleared. That prevents usage like that:

        e := enviper.New(viper.New())
	if err := e.ReadInConfig(); err != nil {
		panic(err.Error())
	}
	if err := e.MergeConfigMap(defaults.AllSettings()); err != nil {
		panic(err.Error())
	}
	if err := e.Unmarshal(&cfg); err != nil {
		panic(err.Error())
	}

Is there a reason why Unmarshal makes a call to ReadInConfig? Afaik, viper itself expects users to call ReadInConfig explicitly before Unmarshal is used

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.