How to use CoffeeScript instead of JSON? For configuration files etc

Viewed 3004

JSON really is a pain to use for local configuration files as it does not support comments or functions, and requires incredibly verbose syntax (commas, always use " for keys). Making it very error prone, or in the case where functions are required, impossible to use.

Now I know that I could just do:

require('coffee-script')
config = require('config.coffee')

However, that requires me to do module.exports = {the data} inside config.coffee which is less than ideal. And even allows for things such as require to be exposed which can make the configuration files insecure if we do not trust them.

Has anyone found a way to read coffeescript configuration files, but keep them secure?

1 Answers
Related