Something like Typesafe Config for NodeJS
Asked Answered
B

1

10

I have a nodejs application that will take a JSON configuration file.

The JSON file will have some ${} and #{} tags that will be used to build up a dynamic context by loading a template configuration and populating the tags. HOCON may also end up being used eventually but that's not in there yet.

I came across Typesafe Config in the past and it looks amazing for this kind of thing. I did a bit of searching around npm and didn't spot anything similar in the node world but perhaps I am too unfamiliar with what terms to search for.

Does anyone know of a similar library in nodejs or a sensible strategy I may employ to do this in nodejs?

I know it wouldn't be much effort to implement something myself with string replace on the JSON or some such although I can't help but think that this has been done before in node applications and probably in a much better way than I would do it for this single use case. On that basis it seems to make sense to ask here before I continue.

Bristle answered 26/1, 2015 at 9:52 Comment(0)
E
3

A bit late, but it seems there is still no dedicated npm module to convert hocon to js. However there is a library which could be easily converted to a npm module : https://github.com/scottburch/webpack-hocon-loader

Ev answered 29/2, 2016 at 16:4 Comment(1)
Nice. I had gone and implemented my own thing for my particular problem but that library looks like a solution. It's very similar to what I did but handles more scenarios than I bothered with.Thanks.Lisalisabet

© 2022 - 2024 — McMap. All rights reserved.