Search code examples
javascriptcoffeescriptexpressscaffolding

Express JS create coffeescript scaffold


Looking for a way to produce an express scaffold in coffeescript straight off the bat.

At the moment $ express 'myapp' just creates js files.

Any pointers will be appreciated. Thanks.


Solution

  • You can transform the created app.js and routes/index.js files into coffeescript using js2coffee (like Slace stated)
    There are two ways:
    1. Manually using the js2coffee.org converter
    2. Using the js2coffee npm package and piping the output into a new file

    $ cd my_new_express_app
    $ sudo npm install js2coffee -g
    Files can now be converted by running js2coffee input.js > output.coffee 
    $ js2coffee app.js > app.coffee
    $ js2coffee routes/index.js > routes/index.coffee
    

    This way you can start a fresh express project in coffeescript. Note that the conversion strips comments away.