admin管理员组

文章数量:1180465

When I run express app_name, expressjs creates all the folders and files needed. I'm wondering if there's a way to do the same but instead of creating the app.js in JS, it creates in CoffeeScript.

Thanks

When I run express app_name, expressjs creates all the folders and files needed. I'm wondering if there's a way to do the same but instead of creating the app.js in JS, it creates in CoffeeScript.

Thanks

Share Improve this question asked Sep 2, 2011 at 14:06 donalddonald 23.7k45 gold badges145 silver badges223 bronze badges
Add a comment  | 

5 Answers 5

Reset to default 12

Try this: https://github.com/twilson63/express-coffee

express-coffee is a template or boiler-plate to get started writing express web applications in CoffeeScript. It comes ready to go with base setup for an Express Web App. It includes a Cakefile that lets you build, spec, and watch your coffeescript as you develop. You hack in the src folder and run cake build to build you server files, write your mocha in your test folder and run cake test or spec to run your test suite. Create your jade views in the views folder and put your public assets in the public folder...

You may want to check out skeleton. I also created frappe, which is similar but tweaked for my taste.

I don't think there's a command-line tool to do this, but there are plenty of template projects you could start from. In particular, I'd recommend sstephenson's node-coffee-project. It's not Express specific, but you can easily throw Express into the package.json and create a src/app.coffee file that looks something like

express = require 'express'
app = express.createServer()
# TODO: configuration
app.listen 3000

The important thing is to have a Cakefile that can do the tasks your project needs. For an Express project, you might want to add a task that not only continuously recompiles your CoffeeScript, but also restarts the server every time you change a source file. Here's a gist of a Cakefile I'm using on one of my projects (you'll have to add "watch-tree" to your `devDependencies).

ExpressOnSteroids Express + SCSS + COFFEE SCRIPT

clone project and start cake task /path/to/cake dev

just found that there is a project called 'zappa' on github that might be helpful to you http://zappajs.org

本文标签: javascriptNodejs Create an Express project using CoffeeScriptStack Overflow