GithubHelp home page GithubHelp logo

twilson63 / express-coffee Goto Github PK

View Code? Open in Web Editor NEW
626.0 31.0 152.0 1.7 MB

A Template for NodeJs Application using Express, CoffeeScript, Jade, Stylus, Nib

Home Page: http://twilson63.github.io/express-coffee

License: MIT License

CoffeeScript 62.59% CSS 1.22% JavaScript 3.20% HTML 32.99%

express-coffee's Introduction

Express Coffee Template 9 (1.9.0)

This is a Node Express CoffeeScript Stack Template

It comes ready to go with connect-assets that give you the option to use coffee-script and stylus for the client side.

Technologies

This is a template that can be used to create nodejs applications using

  • Node v4.2.x
  • Express v4.13.x
  • CoffeeScript v1.10.x
  • Jade v1.11.0
  • Stylus v0.52.x
  • bootstrap-stylus 2.3.1 (not a npm module)
  • Nib v1.1.x
  • Connect Assets v2.5.x
  • MongoDB / Mongoose 3.8.x

Requirements

These will install with npm, just do

npm install

In your project directory.


Install, Build, Run, Test, and Watch

# Install nodejs and npm

git clone http://github.com/twilson63/express-coffee.git [project-name]
cd [project-name]
npm install

Install coffee-script, mocha and docco

npm install coffee-script -g
npm install mocha -g
npm install docco -g

Run

cake dev

Mocha and Request for testing

mocha is an extremely powerful and easy to use testing framework

see http://mochajs.org/

describe 'Sample test', ->
  it 'should be true', ->
    true.should.equal true

to run mocha

cake test

Setup to deploy to heroku

rm -rf .git
git init
echo 'node_modules' >> '.gitignore'
git add .
git commit -am "first commit"
heroku create
git push heroku master
heroku open

Thanks to

About

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. Enjoy your express-coffee

License

See LICENSE

Contribute

pull requests are welcome

express-coffee's People

Contributors

adrienbrault avatar baloo avatar bratsche avatar bsodmike avatar chagel avatar chieffancypants avatar craigulliott avatar darvin avatar fern4lvarez avatar jcollum-hcg avatar jgable avatar jgannonjr avatar jkatsnelson avatar jorritposthuma avatar jpillora avatar kabbi avatar mortonfox avatar okize avatar pengkui avatar rafe avatar ronakr avatar skw avatar spadin avatar twilson63 avatar zacheryph avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

express-coffee's Issues

tests not passing on master

Hi, I just cloned express-coffee.

npm install completed successfully, but running cake test gives me:

➔ cake test

module.js:340
throw err;
^
Error: Cannot find module 'debug'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object. (/Users/sshingler/src/express-coffee/node_modules/stylus/lib/visitor/evaluator.js:23:13)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)

Do you have any idea what could be causing that?

➔ npm -v
1.1.69

Please shout if you need any other info.

Thanks,
Steven

launch with error

Here is Log:

events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: failed to connect to [localhost:27017]
at Server.connect.connectionPool.on.server._serverState (/home/simsun/node/express-coffee/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:530:73)
at EventEmitter.emit (events.js:126:20)
at connection.on._self._poolState (/home/simsun/node/express-coffee/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:104:15)
at EventEmitter.emit (events.js:99:17)
at Socket.errorHandler (/home/simsun/node/express-coffee/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:411:10)
at Socket.EventEmitter.emit (events.js:96:17)
at Socket._destroy.self.errorEmitted (net.js:329:14)
at process.startup.processNextTick.process._tickCallback (node.js:245:9)
DEBUG: Program node server exited with code 1

Mongoose default settings fail on Heroku

I created a quick fix by rapping it in a try / catch so heroku can at least launch. You may want to do something more advanced so its obvious where and what is wrong. As a Rails dev I am used to SQLite just working, this had me scratching my head for a while

src/index.coffee

...

try
  mongoose.connect 'mongodb://localhost/testing'  
catch e
  console.log(e)

Also: Great Job. This pre-build let me get running really quickly.

non-matching bootstrap file versions

They current setup is using non-matching versions of bootstrap css vs js files.

This was causing some weird issues to crop up for me.

from views/layouts.jade:

!= css("//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap.no-icons.min.css")
//other stuff...
!= js('//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js')

I will go ahead and fix this, bump the bootstrap version to the current 2.2.2, and send a pull request.

cake test - gets errors

Thanks for setting up this template. I did a clean install and tried the command:

cake test

And I get the following output:

cake test
path.existsSync is now called fs.existsSync.
path.exists is now called fs.exists.
execvp(): No such file or directory

My environment:

express --version
3.0.0rc1
node --version
v0.8.2

Is this because I'm using Node 0.8?

What abwt using brunch.io?

Brunch.io is an application assembler.
It makes sense to use if if your front end code is using front end mvc's like backbonejs.
It also provides browser autoreload functionality once any client file is changed.

Integrating it with express is pretty straighfoward: express's public dir is actually brunch's public dir!

Brunch would also replace connect-assets.
So, what do you think about it? :)

P.S. I've been personally using it in production for a while now. It is also used at delicious and Uber :P

Unexpected 'IDENTIFIER'

I'm sure this is an issue with my lack of understanding but I thought you might be able to clarify. When I add a second line to index.coffee like:

h2 'test'

I always get the error below. No matter what I seem to add, if there is a second line in that file, it blows up.

Error: Parse error on line 1: Unexpected 'IDENTIFIER'
at Object.parseError (/Users/ehauser/working/express-coffee/node_modules/coffeekup/node_modules/coffee-script/lib/parser.js:472:11)
at Object.parse (/Users/ehauser/working/express-coffee/node_modules/coffeekup/node_modules/coffee-script/lib/parser.js:548:22)
at Object.compile (/Users/ehauser/working/express-coffee/node_modules/coffeekup/node_modules/coffee-script/lib/coffee-script.js:29:22)
at Object.compile (/Users/ehauser/working/express-coffee/node_modules/coffeekup/lib/coffeekup.js:186:25)
at Function.compile (/Users/ehauser/working/express-coffee/node_modules/express/lib/view.js:64:33)
at ServerResponse._render (/Users/ehauser/working/express-coffee/node_modules/express/lib/view.js:413:18)
at ServerResponse.render (/Users/ehauser/working/express-coffee/node_modules/express/lib/view.js:313:17)
at Router. (/Users/ehauser/working/express-coffee/app.coffee:9:21)
at done (/Users/ehauser/working/express-coffee/node_modules/express/lib/router/index.js:250:22)
at middleware (/Users/ehauser/working/express-coffee/node_modules/express/lib/router/index.js:244:9)

error in `cake dev` related to piping

Thanks for making this express-coffee project, I'm happy to have found it!

I'm having a little trouble with the cake dev task -- the server won't start and I see an error:

$ cake dev                                                                                                                                                                                                                                       
Watching coffee files
Watching js files and running server

DEBUG: Running node-supervisor with
DEBUG:   program 'server'
DEBUG:   --watch '.app,views'
DEBUG:   --ignore 'undefined'
DEBUG:   --extensions 'js|jade'
DEBUG:   --exec 'node'
DEBUG: Starting child process with 'node server'
DEBUG: Watching directory '/Users/greg/workspace/self/shortlist_express_coffee/.app' for changes.
DEBUG: Watching directory '/Users/greg/workspace/self/shortlist_express_coffee/views' for changes.

/Users/greg/workspace/self/shortlist_express_coffee/server.js:8
app.listen(port, function() {
    ^
TypeError: Object #<Object> has no method 'listen'
    at Object.<anonymous> (/Users/greg/workspace/self/shortlist_express_coffee/server.js:8:5)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3
DEBUG: Program node server exited with code 8

DEBUG: Starting child process with 'node server'
..... [repeats 3 times]

However, when I commented out either of the lines that pipe the supervisor's output streams to stdout and stderr, there is no error displayed and the server starts. These lines are 96 and 97 in the Cakefile in master@HEAD of as now.

Weird. Any ideas what the problem is?

incompatible versions during NPM install

It appears some of the package versions are incompatible.

npm http 304 https://registry.npmjs.org/connect
npm ERR! error installing [email protected]

npm ERR! Error: No compatible version found: connect@'>=1.8.5- <1.9.0-'
npm ERR! Valid install targets:
npm ERR! ["0.0.1","0.0.2","0.0.3","0.0.4","0.0.5","0.0.6","0.1.0","0.2.0","0.2.1","0.2.2","0.2.3","0.2.4","0.2.5","0.2.6","0.2.7","0.3.0","0.4.0","0.5.0","0.5.1","0.5.2","0.5.3","0.5.4","0.5.5","0.5.6","0.5.7","0.5.8","0.5.9","0.5.10","1.0.0","1.0.1","2.2.2","2.3.0","2.3.1","2.3.2","2.3.3","1.9.1","2.3.4","2.3.5","2.3.6","2.3.7","1.9.2","2.3.8","2.3.9","2.4.0","2.4.1","2.4.2","2.4.3","2.4.4","2.4.5","2.4.6","2.5.0","2.6.0","2.6.1","2.6.2","2.7.0","2.7.1","2.7.2","2.7.3"]
npm ERR!     at installTargetsError (/usr/local/lib/node_modules/npm/lib/cache.js:488:10)
npm ERR!     at next_ (/usr/local/lib/node_modules/npm/lib/cache.js:438:17)
npm ERR!     at next (/usr/local/lib/node_modules/npm/lib/cache.js:415:44)
npm ERR!     at /usr/local/lib/node_modules/npm/lib/cache.js:408:5
npm ERR!     at saved (/usr/local/lib/node_modules/npm/lib/utils/npm-registry-client/get.js:147:7)
npm ERR!     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:231:7
npm ERR!     at Object.oncomplete (fs.js:297:15)

Express Coffee is set to compile stylus at every request on production

Hello, I'm new to the Node and probably do something wrong, but != css('app') is not cached in production mode.

!= css('app') // 516 MS response latency
//!= css('app') // 7 MS response latency

Css link at each request is not changed and looks like

<link rel='stylesheet' href='/css/app-1793ea5a0889a0772f020b0aae293a5b.css'>

If I request CSS directly with the browser, latency is 2MS.

Am I doing something wrong or it's just a bug? I use express coffee and assets version is 2.3.3

Thank you,
Serge

Concurrent connections only one

I'am starting server with:

cake dev

After I want to test my site with ab.

ab -n 1 -c 1 http://127.0.0.1:3001/

This works fine but this

ab -n 2 -c 1 http://127.0.0.1:3001/

works bad... returns:

This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)...apr_poll: The timeout specified has expired (70007)

How to fix this ?

My server.js file:

// Generated by CoffeeScript 1.4.0
var app, port;

app = require('./.app');

port = app.port;

app.listen(port, function() {
  return console.log("Listening on " + port + "\nPress CTRL-C to stop server.");
});

Where do I put images?

Hi,

This question might look stupid...

I installed express-coffee and it works perfectly. My only issue is I don't know where to put my images folder and how to reach them with jade and stylus.

For my defense, see, I'm a designer and this node express stuff doesn't read at all for me :~( I know how to code with jade and stylus and that's it...

I really like this bootstrap, I just need this extra info about how to set up images folder and how to reach it.

Cheers!

-Adame

bootstrap or watch (Default)

What should be the express-coffee default, requiring users to build and watch their project or using the coffee-script bootstrap to dynamically load your coffee files?

I would like to make this change with the release of express 3.0

Cloud9 IDE requires the dynamic bootstrap, but I have been using the build and watch lately in combination with node-dev to automatically re-compile and restart my dev environment.

What should be the best practice?

What is the most efficient for new users to get started?

When I first created this template, it worked great for having a quick way to get started, express is changing and I would like this template to change with the new features so it can be a quick on ramp for anyone that would like to use express and coffee-script.

Any Suggestions?

Tests don't run due to case mismatch

Running cake test dies for me on Linux, as it's calling for files with a different case than the files on disk.

posts_test.coffee
line 3
Post = require process.cwd() + '/.app/models/Post'
should be
Post = require process.cwd() + '/.app/models/post'
---------------------------------------------^

users_test.coffee
line 3
User = require process.cwd() + '/.app/models/User'
should be
User = require process.cwd() + '/.app/models/user'
---------------------------------------------^

question: why did you remove Cakefile for 1.2RC?

Hello, this isn't really an issue, just a question. I noticed viewing the history that you used to have a Cakefile with build and watch tasks for compiling .coffee files into .js files. With your commit for 1.2RC you switched to simply having server.js require 'coffee-script' and have it interpret .coffee files on the fly. Is there a reason in particular you did that? What kind of performance hit does executing coffee files involve? I'd be grateful for any advice in that regard.

Thanks,
Ben

erm, then I followed the link for http://express-coffee.wilbur.io/ and read the answer:

express-coffee template is made to quickly start putting together an application/prototype. So we have changed the template back to automatically compile the coffee-script when you run your node app.

That makes sense, as it is certainly simpler and easier not to bother with compiling, but perhaps it would be worth leaving the build option for folks who want to move from prototyping to real development and deployment?

Actively maintained bootstrap-stylus repo

I know that you guys started linking to a bootstrap cdn, I thought I would mention this bootstrap-stylus repo because it's being actively maintained. The author checks diffs and manually updates stylus libs.

Benefits:

  • variables
  • easily include required bootstrap modules
  • styles written in stylus

Some ideas?

I was thinking of making some changes in the somewhat near future and replacing some (somewhat core) dependencies like:

connect-assets -> asset-rack

asset-rack is much easier to configure and write plugins for. connect-assets v3 looks cool but the development is slow and asset-rack already offers the same options and then some

bootrap-stylus -> axis-css

Axis is a Stylus library that is somewhere in between bootstrap and nib.

consolidate.js

Express doesn't need consolidate.js to configure it, but I figure if we have it in the code as a sample it'll be easy to swap templates.

Thoughts?

Err: TypeError: Bad argument

My versions:

  • node v0.4.11
  • npm v1.0.27
  • express v2.4.6
  • CoffeeScript version 1.1.2
  • coffeekup version 0.3.0
(master)$ coffee app.coffee 
TypeError: Bad argument
    at Object.stat (fs.js:388:11)
    at HTTPServer.listen (net.js:1051:19)
    at Object.<anonymous> (/users/mike/nodejs/express-coffee/app.coffee:11:7)
    at Object.<anonymous> (/users/mike/nodejs/express-coffee/app.coffee:12:4)
    at Module._compile (module.js:402:26)
    at Object.run (/usr/local/lib/node_modules/coffee-script/lib/coffee-script.js:57:25)
    at /usr/local/lib/node_modules/coffee-script/lib/command.js:147:29
    at /usr/local/lib/node_modules/coffee-script/lib/command.js:115:26
    at [object Object].<anonymous> (fs.js:107:5)
    at [object Object].emit (events.js:61:17)

and

(master)$ node server.js 

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
TypeError: Bad argument
    at Object.stat (fs.js:388:11)
    at HTTPServer.listen (net.js:1051:19)
    at Object.<anonymous> (/users/mike/nodejs/express-coffee/app.coffee:11:7)
    at Object.<anonymous> (/users/mike/nodejs/express-coffee/app.coffee:12:4)
    at Module._compile (module.js:402:26)
    at Object.<anonymous> (/usr/local/lib/node_modules/coffee-script/lib/coffee-script.js:14:21)
    at Module.load (module.js:334:31)
    at Function._load (module.js:293:12)
    at require (module.js:346:19)
    at Object.<anonymous> (/users/mike/nodejs/express-coffee/server.js:2:1)

Any thoughts on this? Thanks.

Mocha runs tests twice

Trying to add new tests in coffee script inside ./test directory.

But with cake test command tests run (and count) twice. If test failing error message prints also twice.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.