Something like Typesafe Config for NodeJS - json

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.

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

Related

Best practice for sending data between groovy and powershell processes?

I'm currently working on a project that has front-end components (Jira) written in groovy, and backend processes written in powershell. We're using json to pass information back and forth. One of the biggest problems we've encountered is coming up with a standardized "template" for the json that is being used on both ends. What we have works, but it is a frankenstein mess.
We are using json libraries for both json and powershell -- the json that is being constructed on either end is legit json. We are also encoding it to base64 to get around interpolation issues we've run into.
My main question is this: what is the best practice for passing data between different tools in json? I'm relatively new to it. Is there some sort of standard template we should be adhering to? I develop the groovy side, my friend the powershell side -- I was hoping to come up with something that would minimize problems if someone messed up how the json was constructed on either side. Something to check against. Something akin to an xsd.
Was curious if people have dealt with this type of thing, and what the best approach was. As I mentioned before, we have something that works now -- with error handling and whatnot, but it was very organic... and not standardized at all. I saw mention of jasonp, jsend, etc., but having some difficulty groking the options.
Tips/guidance appreciated.

Is this a job for Yeoman?

I use Yeoman, and I dig it.
However recently I have been wanting more complex code generation tools - now I know I can build custom generators, but I am wondering if people think this is the role/job/whatever that Yeoman is built to play.
Examples are,
Generating a base REST API (in Node) from a JSON schema
Generating MySQL DB Schema from JSON schema etc.
Although I could bend Yeoman to do this - do people think this is a realistic direction?
Is there a better tool for the job?
(Currently I have a bunch of custom Node scripts that suffice).
My humble opinion:
Yeoman is first and foremost a front end tool to create webapps.
Your task seems to be backend related.
You can still use grunt to scaffold your project though.
http://gruntjs.com/project-scaffolding
Cheers

Building a networking event system, what data format should I use?

I'm using Node.js to build an event based game server (to a flash client). But, I'm having trouble finding examples of how I should architect this message passing.
To simplify things, I was thinking in using a json:
{signature: 'event_name', { /* event data /*} }
So I can easily write to socket using any serialization library. Is it a good idea? Please point me to articles, tutorials or books if you think I don't know what I'm doing at all (which I think is the case)
I would use AMF. There is a pure javascript version of it: http://www.jamesward.com/2010/07/07/amf-js-a-pure-javascript-amf-implementation/
BSON is what you are looking for, it has similar properties to JSON, but it a lot smaller and faster to parse. The MongoDB driver for node has a BSON library in it, I don't know about any Flash librarys though.

Creating a language on the Rubinius VM

I'm looking to play around with the Rubinius VM to create a langauage, but just reading the documentation, I'm still quite lost on how to get started. Even looking at the projects, I still can't seem to figure out where the parsing and using the vm comes into place. Does anyone have any resources for this?
Hey I'm a contributor to the Fancy language that runs on rubinius. If you're interested in parsing take a look at boot/rbx-compiler there you'll find a Parser (implemented with KPEG) that basically constructs a tree of AST nodes, each of those nodes has a bytecode method that produces the rubinius vm instructions for everything to work. Fancy share a lot of semantics with ruby, so I guess starting with it would be easy if you're already familiar with ruby. You'll just need to checkout the examples/ dir to geet a feeling on the language and then the kpeg parser, ast nodes, loader, as you progress exploring the compiler. These days Fancy is bootstrapped (that means that the compiler has been written in fancy itself - at lib/compiler) but rbx-compiler is the first step in that process.
Hope exploring Fancy's source code can be of help to you.
In case you hadn't seen it, check out Evan's keynote from 2011 LA Ruby Conf. He shows how to build a simple language, which might be helpful.

Handling properties in Scala

I'd like to know what is the most efficient way of handling properties in Scala. I'm tired of having gazillion property files, xml files and other type of configuration files in Java and wonder if there's "best practice" to handle those someway more efficient in Scala?
Why would you have a gazillion property files?
I'm still using the Apache commons Digester, which works perfectly well in Scala. It's basically a very easy way of making a user-defined XML document map to method calls on a user-defined configurator class. I find it extremely useful when I want to parse some configuration data (as opposed to application properties).
For application properties, you might either use a dependency injection framework (like Spring) or just plain old property files. I'd also be interested to see if Scala offers anything on top of this, though.
EDIT: Typesafe config gives you a simple and powerful solution for configuration - https://github.com/typesafehub/config
ORIGINAL (possibly not very useful):
Quoting from "Programming in Scala":
"In Scala, you can configure via Scala code itself."
Scala's runtime linking allows for classes to be swapped at runtime and the general philosophy of these languages tends to favour convention over configuration. If you don't want to deal with gazillion property files, just don't have them.
Check out Configgy which looks like a neat little library. It includes nesting and change-notification. It also include a logging library.
Unfortunately, it didn't compile for me on the Mac instances I tried. Let us know if you have better luck and what you think...
Update: solved Mac compilation problems. See this post.