Giter Club home page Giter Club logo

zappa's People

Contributors

agnoster avatar aldonline avatar dvv avatar esamattis avatar mauricemach avatar rachel-carvalho avatar shimaore avatar smathy avatar timshadel 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

zappa's Issues

client_routes.coffee demo broken (in fact sammy)

Installing zappa with 'npm install -g zappa', I try to run client_routes.coffee.

In the debug output, I see ReferenceError: ren is not defined
In web inspector I see that sammy.js was not loaded.

Also, I had to use safari because websockets get disconnected with chrome.

running

ack --nocolor --nogroup -w -- ren

on the zappa hierarchy I got

...
lib/zappa.js:406: return ren.send(sammy);
src/zappa.coffee:283: ren.send sammy
...

Sounds like a typo to me, "ren" should read "res".

Ajax post request parameters are not visible in the handler

In the following example the value of @finding which is printed in the console is undefined:

require('zappa') ->

  get '/': ->
    render 'home'

  view home: ->
    table ->
      td -> label 'Finding: '
      td -> input type:'text',id:'finding_text'
      td -> input type:'button',id:'submit_finding',value:'Submit'
      script src: '/study.js'


  coffee '/study.js': ->
    $('#submit_finding')
      .click ->
        finding = $('#finding_text').val()
        unless finding is ''
          $.ajax
            type: 'post'
            url: '/submit_finding'
            dataType: "json"
            data: 
              finding: finding

            success: ->
              $('#finding_text').val('')



  post '/submit_finding': ->
    console.log @finding

    send 
      result: 'Ok'


  view layout: ->
    html ->
      head ->
        script src: 'http://code.jquery.com/jquery-1.6.2.min.js'
      body ->
          @body

As soon as I change 'post' to 'get' in the ajax request type and the handler, the value of @finding is properly set.

I checked the ajax request details in the Chrome console: the finding parameter is properly sent, so it is probably not jQuery's fault.

What could be the reason for this?

navigator is not defined

P.S: I think it is a jquery error. I have also added issue to node-jquery.

$ cat /etc/issue
Ubuntu 10.10 \n \l

$ node -v
0.2.5

$ npm ls installed

$ npm ls installed
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
[email protected] Unfancy JavaScript =jashkenas installed latest remot
[email protected] Markup as CoffeeScript. =mauricemach installed lates
[email protected] High performance middleware framework =creationix =t
[email protected] High performance middleware framework =creationix =t
[email protected] High performance middleware framework =creationix =t
[email protected] Middleware for Connect (node.js) for handling your auth
[email protected] Middleware for Connect (node.js) for handling your auth
[email protected] Redis session store for Connect =tjholowaychuk insta
[email protected] A simple wrapper for sendmail. =aaron installed late
[email protected] Sinatra inspired web development framework =tjholowa
[email protected] Sinatra inspired web development framework =tjholowa
[email protected] TDD framework, light-weight, fast, CI-friendly =tjho
[email protected] TDD framework, light-weight, fast, CI-friendly =tjho
[email protected] a customizable value inspector =cloudhead installed
[email protected] Misc routines for Facebook Apps developing with node.js
[email protected] easy peasy facebook client =masylum installed latest
[email protected] Simple pub/sub messaging for the web =jcoglan instal
[email protected] Forgiving HTML/XML/RSS Parser in JS for both Node and
[email protected] Jade template engine =tjholowaychuk installed remote
[email protected] Jade template engine =tjholowaychuk installed latest
[email protected] jQuery: The Write Less, Do More, JavaScript Library
[email protected] CommonJS implementation of the DOM intended to be platf
[email protected] Leaner CSS =cloudhead installed remote css parser le
[email protected] Leaner CSS =cloudhead installed latest remote css pa
[email protected] =astro installed latest remote
[email protected] send emails from node.js to a smtp server, simple as ca
[email protected] Command line mjsunit runner which provides an easy way
[email protected] NodeJS binding for fast XML parsing. =astro installe
[email protected] NodeJS binding for fast XML parsing. =astro installe
[email protected] ICU StringPrep profiles =astro installed latest remo
[email protected] installed
[email protected] Idiomatic XMPP client, component & server library for n
[email protected] A package manager for node =isaacs installed latest
[email protected] Library for interacting with OAuth 1.0, 1.0A and 2. Pr
[email protected] Display and verify a Recaptcha captcha =mirhampt ins
[email protected] Redis client library =mjr installed remote
[email protected] Redis client library =mjr installed latest remote
[email protected] Simplified HTTP request method. =mikeal installed la
[email protected] The cross-browser WebSocket =rauchg =Tim-Smart insta
[email protected] Asynchronous BDD & continuous integration for node.js
[email protected] Simple to use HTTP library on top of the built in libs
[email protected] Razor-sharp DSL for modern web apps. =mauricemach in
npm ok

$ zappa cuppa.coffee
ReferenceError: navigator is not defined
at /home/alfred/local/lib/node/.npm/jquery/1.4.3/package/lib/jquery-1.4.3.js:85:14
at /home/alfred/local/lib/node/.npm/jquery/1.4.3/package/lib/jquery-1.4.3.js:917:4
at create (/home/alfred/local/lib/node/.npm/jquery/1.4.3/package/lib/jquery-1.4.3.js:6895:4)
at /home/alfred/local/lib/node/.npm/jquery/1.4.3/package/lib/jquery-1.4.3.js:6899:18
at Object. (/home/alfred/local/lib/node/.npm/jquery/1.4.3/package/lib/jquery-1.4.3.js:6903:1)
at Module._compile (node.js:462:23)
at Module._loadScriptSync (node.js:469:10)
at Module.loadSync (node.js:338:12)
at loadModule (node.js:283:14)
at require (node.js:411:14)

Error: Cannot find module 'zappa' (zappa 0.2.0beta, npm 1.0.1rc5, node v0.5.0-pre)

I know this issue has been covered before (#27, #34) but I just wanted to point out it is again a factor with new versions of npm, node, and zappa.

Running the commands in the documentation:

npm install node
coffee cuppa.coffee

I get: Error: Cannot find module 'zappa'

If I alter cuppa.coffee to read require('./node_modules/zappa') ->, things work.

I did try setting my $NODE_PATH environment variable as some of the earlier fixes suggested, but that did not help.

Sorry if I missed the solution in the other tickets, or am just not thinking clearly. Thanks for Zappa!

(OS X 10.6.8)

Mimic express/rails executable generator-server behaviour

The express binary is able to generate apps as well as run them and I believe zappa should provide this facility.

For instance when running

zappa

should look for "app.coffee" in the current directory and operate as if the command were...

zappa app.coffee

When running zappa against a file that does not exist...

zappa does_not_exist

...it should create a scaffold application at the specific target (in this case in the folder "does_not_exist").

Perhaps there should be a "generate" flag to avoid costly mistakes.

zappa facebook_killer
> Error: ENOENT, No such file or directory 'facebook_killer'

zappa --generate facebook_killer
> generated new zappa app in facebook_killer
> generated facebook_killer/app.coffee
> generated facebook_killer/README.md

Although I'm not convinced this is necessary, it's more verbose/complex and it deviates from the accepted standard.

Furthermore...

zappa --template websockets facebook_killer

should utilise the websockets example from examples/websockets.coffee as a basis for the new zappa project.

Ultimately, I accept this is something @mauricemach and others might want to avoid. It's probably not a sinatra-ism and I must warn you that simpler frameworks like Sinatra are not largely part my background. Perhaps it may destroy the aura of simplicity about a zappa app. Nevertheless, I personally believe this is desirable behaviour.

Please chime in with your thoughts. I will begin work on the patch if @mauricemach approves, others are interested and it's not being attempted.

Syntax Error

Running:

$ zappa cuppa.coffe 

I get:

undefined:16
}; with(locals) {return (function () {get '/': 'hi'}).apply(context, args);}
                                          ^^^
SyntaxError: Unexpected string
    at Object.Function (unknown source)
    at /usr/local/lib/node_modules/zappa/lib/zappa.js:674:12
    at Zappa.define_with (/usr/local/lib/node_modules/zappa/lib/zappa.js:54:14)
    at Zappa.run (/usr/local/lib/node_modules/zappa/lib/zappa.js:88:12)
    at Zappa.run_file (/usr/local/lib/node_modules/zappa/lib/zappa.js:79:19)
    at Object.run_file (/usr/local/lib/node_modules/zappa/lib/zappa.js:700:23)
    at /usr/local/lib/node_modules/zappa/lib/cli.js:133:26
    at path.js:292:19

Every things works fine if I compile cuppa.coffe and then running it with node node cuppa.js

After npm update, @ context variables no longer available in views

First -- huge thanks for Zappa/Coffeekup. Absolutely wonderful.

After I just ran npm update, my Zappa apps stopped being able to see @ context variables within the views. To use the example from the Zappa documentation:

get '/:foo': ->
  @foo += '!'
  render 'index'

view index: ->
  h1 'You said:'
  p @foo


layout ->
  html ->
    head -> title "You said: #{@foo}"
    body -> @content

yields:

<html><head><title>You said: undefined</title></head><body></body></html>

Things were working great until just before the update. Here's what my npm update versions look like:

$ sudo npm update 
Password:
[email protected] ./node_modules/zappa/node_modules/coffeekup/node_modules/coffee-script
[email protected] ./node_modules/zappa/node_modules/coffeekup
[email protected] ./node_modules/mongoose/node_modules/hooks
[email protected] ./node_modules/mongoose/node_modules/colors

> [email protected] install /Users/russ/node_modules/mongoose/node_modules/mongodb
> bash ./install.sh

================================================================================
=                                                                              =
=  To install with C++ bson parser do <npm install mongodb --mongodb:native>   =
=  the parser only works for node 0.4.X or lower                               =
=                                                                              =
================================================================================
Not building native library for cygwin
[email protected] ./node_modules/mongoose/node_modules/mongodb
[email protected] ./node_modules/mongoose
[email protected] ./node_modules/zappa/node_modules/express/node_modules/mime
[email protected] ./node_modules/zappa/node_modules/express/node_modules/qs
[email protected] ./node_modules/zappa/node_modules/express/node_modules/connect/node_modules/mime
[email protected] ./node_modules/zappa/node_modules/express/node_modules/connect/node_modules/qs
[email protected] ./node_modules/zappa/node_modules/express/node_modules/connect
[email protected] ./node_modules/zappa/node_modules/express
[email protected] ./node_modules/zappa/node_modules/socket.io/node_modules/policyfile
[email protected] ./node_modules/zappa/node_modules/socket.io/node_modules/redis
[email protected] ./node_modules/zappa/node_modules/jquery/node_modules/htmlparser
[email protected] ./node_modules/zappa/node_modules/socket.io/node_modules/socket.io-client/node_modules/uglify-js
[email protected] ./node_modules/zappa/node_modules/socket.io/node_modules/socket.io-client
[email protected] ./node_modules/zappa/node_modules/socket.io
[email protected] ./node_modules/zappa/node_modules/jquery/node_modules/jsdom/node_modules/request
[email protected] ./node_modules/zappa/node_modules/jquery/node_modules/jsdom/node_modules/cssom
[email protected] ./node_modules/zappa/node_modules/jquery/node_modules/jsdom/node_modules/htmlparser
[email protected] ./node_modules/zappa/node_modules/jquery/node_modules/jsdom
[email protected] ./node_modules/zappa/node_modules/jquery

helpers and defs are not availabe in views

They are available in the get and post type functions.

In order to get anything into a view, one has to pass it in explicitly from the get-type function to the view.

def a: 'asdf'

get '/': ->
  @a = a
  render 'index'

view index: ->
  a # undefined
  @a # asdf

require('jquery')

Hi! I have 'window is not defined', 'navigator is not defined' and so on at zappa.coffee L7. How do you manage to require('jquery')? Is it github.com/jquery/jquery?

--Vladimir

Error handling customization

How can I customize the error handling in zappa, e.g. to render a specific view in case if an unexpected exception is thrown? In express this can be done with app.error(), but it does not seem to work in zappa.

In the default setting zappa does not even respond to the client when an Error is thrown in a 'get' handler. Moreover, it completely stops working and will not serve any subsequent requests.

Heroku fails to install zappa dependency via npm

A git push heroku command ultimate results in the following snippet (perhaps it's an npm bug):

   > 

-----> Heroku receiving push
-----> Node.js app detected
-----> Vendoring node 0.4.7
-----> Installing dependencies with npm 1.0.8

   > [email protected] install /tmp/build_34k61587jt8zz/node_modules/mongoose/node_modules/mongodb
   > bash ./install.sh

   ================================================================================
   =                                                                              =
   =  To install with C++ bson parser do <npm install mongodb --mongodb:native>   =
   =  the parser only works for node 0.4.X or lower                               =
   =                                                                              =
   ================================================================================
   Not building native library for cygwin
   npm ERR! error installing [email protected] Error: ENOENT, No such file or directory '/tmp/build_34k61587jt8zz/node_modules/zappa/bin/zappa'
   npm ERR! Error: ENOENT, No such file or directory '/tmp/build_34k61587jt8zz/node_modules/zappa/bin/zappa'
   npm ERR! Report this *entire* log at:
   npm ERR!     <http://github.com/isaacs/npm/issues>
   npm ERR! or email it to:
   npm ERR!     <[email protected]>
   npm ERR! 
   npm ERR! System Linux 2.6.18-xenU-ec2-v1.2
   npm ERR! command "/mnt/slug-compiler/language_packs/node/vendor/node/node-0.4.7/node" "/mnt/slug-compiler/language_packs/node/vendor/npm/npm-1.0.8/cli.js" "install"
   npm ERR! 
   npm ERR! Additional logging details can be found in:
   npm ERR!     /tmp/build_34k61587jt8zz/npm-debug.log
   npm not ok

! Failed to install dependencies with npm
! Heroku push rejected, failed to compile Node.js app

jquery and socket.io include order important

I'm not even sure if this is a zappa bug, but it certainly caught me off guard. I hit problems when I included jquery before socket.io like so:

    script src: '/zappa/jquery.js'
    script src: '/socket.io/socket.io.js'

That causes the following in the browser console:

Uncaught ReferenceError: io is not defined
    (anonymous function)                                        socket.io.js:463
 Uncaught ReferenceError: io is not defined
    zappa.run.root_locals.connect                               zappa.js:1
    (anonymous function)                                        :3
    anonymous                                                   :17
    zappa.run                                                   zappa.js:1
    (anonymous function)                                        index.js:1

Switching the order of those two scripts resolves the error. Any idea why this is happening?

postrender does not apply to layout

It makes sense to apply postrenders ( using jQuery against the generated DOM ) to the final generated page ( view + layout ), not just the view.

In my case, I needed it to selectively remove a login button located at the top of the page when the user is logged in.

Automatically compile CoffeeScripts in the public directory

At the moment if you have CoffeeScript as FILE.coffee in the public directory there is no way for it to be compiled and served as JavaScript.

It would be nice if hitting a non-existant FILE.js would render the CoffeeScript if there is a corresponding file.

zappa should accept multiple ports as separate flags and not a list

To be more like coffee, zappa should take ports as separate flags

zappa --port 1234 --port 5678 app.coffee

instead of the current

zappa --port 1234,5678 app.coffee

It's more coffee, more "correct" and cuts down on the manual processing of ports in zappa by leveraging the facilities made available by coffee

An example Cakefile would be as follows
option '-p', '--port [PORTS*]', 'port to listen on'
task 'server', 'server', (options) ->
console.log options

With the usage...

cake -p 1234 -p 5678 server
# { arguments: [ 'server' ], port: [ '2', '3' ] }

I'll patch this if we approve of this behaviour.

Second client-side zappa example fails with error in browser

In app.coffee:

require('zappa') ->
  get '/': -> render 'index', layout: no

  at connection: -> emit 'server time', time: new Date()

  client '/index.js': ->
    def sum: (a, b) -> a + b

    get '#/': ->
      alert 'index'

    at 'server time': ->
      alert "Server time: #{@time}"

    connect 'http://localhost'

  view index: ->
    doctype 5
    html ->
      head ->
        title 'Client-side zappa'
        script src: '/socket.io/socket.io.js'
        script src: '/zappa/zappa.js'
        script src: '/index.js'
      body ''

running the server:

$ coffee app.coffee

yields the following error:

zappa.js:1 Uncaught TypeError: Cannot call method 'get' of undefined

This is on Chrome (Stable Channel) 13.0.782.112. I get a very similar error in Firefox.

Here's npm ls in case that's useful:

└─┬ [email protected] 
  ├── [email protected] 
  ├─┬ [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ └── [email protected] 
  ├─┬ [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ └── [email protected] 
  └─┬ [email protected] 
    ├── [email protected]  extraneous
    ├── [email protected] 
    ├── [email protected] 
    └─┬ [email protected] 
      └── [email protected] 

Static compile option doesn't honor port setting

It does not seem possible to set an alternative server port while doing a static compile. The expected outcome of the following command:

zappa -c -p 8080 app.coffee

Expected: Should be a static version of the app that runs on port 8080:

$ node app.js
App "default" listening on *:8080...

Actual:

$ node app.js
App "default" listening on *:5678...

Integration with css generation library

Zappa uses CoffeKup as default template engine. They fit into each other very well. It's a good idea that templates use the same language as server-sive (and client-side, too), dropping out another layer of abstraction such as some specific template syntax (or at least making it more transparent).
How about writing css the same way? There are a lot of fans of Stylus (http://learnboost.github.com/stylus/), and it's really cool. But I'd like to propose to integrate zappa with other cool, but less known, library https://github.com/aeosynth/ccss. It makes possible to write styles in CoffeeScript, so you will gain the same benefits the CoffeeKup gives. I already implemented it in my fork of zappa and can post the changesets.

error running zappa

in cygwin, i get this error:

$ zappa cuppa.coffee
Error: ENOENT, No such file or directory 'node'
    at Object.openSync (fs.js:167:18)
    at Object.readFileSync (fs.js:88:15)
    at Zappa.read (/usr/local/lib/node/.npm/zappa/0.1.3/package/lib/zappa.js:67:17)
    at Zappa.run_file (/usr/local/lib/node/.npm/zappa/0.1.3/package/lib/zappa.js:71:75)
    at Object.run_file (/usr/local/lib/node/.npm/zappa/0.1.3/package/lib/zappa.js:650:23)
    at Object. (/usr/local/lib/node/.npm/zappa/0.1.3/package/bin/zappa.coffee:96:15)
    at Object. (/usr/local/lib/node/.npm/zappa/0.1.3/package/bin/zappa.coffee:100:4)
    at Module._compile (node.js:329:23)
    at Object.run (/usr/local/lib/node/.npm/coffee-script/1.0.0/package/lib/coffee-script.js:55:19)
    at /usr/local/lib/node/.npm/coffee-script/1.0.0/package/lib/command.js:120:29

Using node 0.3.1. Here is my package situation:

$ npm list installed
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
[email protected]    Unfancy JavaScript    =jashkenas active installed latest remote stable javascript language coffe
[email protected]        Markup as CoffeeScript.    =mauricemach active installed latest remote template view coffeescrip
[email protected]          High performance middleware framework    =creationix =tjholowaychuk active installed latest remo
[email protected]          Sinatra inspired web development framework    =tjholowaychuk active installed remote framework s
[email protected]          Sinatra inspired web development framework    =tjholowaychuk installed latest remote framework s
[email protected]       Forgiving HTML/XML/RSS Parser in JS for *both* Node and Browsers    =tautologistics active insta
[email protected]           jQuery: The Write Less, Do More, JavaScript Library    =coolaj86 active installed latest remote
[email protected]           CommonJS implementation of the DOM intended to be platform independent and as minimal/light as p
[email protected]   Command line mjsunit runner which provides an easy way to hook into mjsunit and start running te
[email protected]           A package manager for node    =isaacs active installed latest remote package manager modules ins
[email protected]         Simplified HTTP request method.    =mikeal active installed latest remote
[email protected]        The cross-browser WebSocket    =rauchg =Tim-Smart active installed latest remote
[email protected]            Razor-sharp DSL for modern web apps.    =mauricemach active installed latest remote framework we
npm ok

coffee and node work independently

$ cat test.coffee
console.log 'Test'

$ coffee test.coffee
Test

Help!

"Can't use mutable header APIs after sent." on examples/async.coffee

Steps to reproduce:
Launch async.coffee from zappa's examples in Chrome (on Firefox it's OK). Try to get index page http://localhost:5678/ (not /bar).

Exception traceback:

http.js:543

    throw new Error("Can't use mutable header APIs after sent.");

      ^

Error: Can't use mutable header APIs after sent.
    at ServerResponse.getHeader (http.js:543:11)
    at ServerResponse.header (/usr/lib/node_modules/zappa/node_modules/express/lib/response.js:241:17)
    at ServerResponse.send (/usr/lib/node_modules/zappa/node_modules/express/lib/response.js:66:17)
    at Object.render (/usr/lib/node_modules/zappa/lib/zappa.js:515:21)
    at Object.<anonymous> (eval at <anonymous> (/usr/lib/node_modules/zappa/lib/zappa.js:674:12))
    at Object._onTimeout (eval at <anonymous> (/usr/lib/node_modules/zappa/lib/zappa.js:674:12))
    at Timer.callback (timers.js:83:39)

"session requires the "secret" option string for security"

Hey ya. Lovely looking lib!

I went to give it a go, and whenever calling zappa on even the simplest example, I'm getting

→ zappa cuppa.coffee 

/usr/local/lib/node/.npm/connect/0.5.5/package/lib/connect/middleware/session.js:45
      throw new Error('session requires the "secret" option string for securit
            ^
Error: session requires the "secret" option string for security

Seems I'm missing something. Any ideas? Thanks!

Add connect middleware / expose Express app

In looking at the possibility of adding middleware to zappa apps, I noted that there doesn't seem be be a way to get access to the Express app itself. This means that plugging in 3rd party middleware is not an obvious process and seems to require tweaking zappa itself.

Error: EBADF, Bad file descriptor '/usr/local/lib/node/.npm/zappa/0.2.0beta/package/lib/../node_modules/jquery/dist/node-jquery.min.js'

Just installed 0.2.0b via cloning this repo and npm'ing. This output is thrown whenever I try to run something.coffee:

Horchata:examples harad$ coffee hi.coffee
Error: EBADF, Bad file descriptor '/usr/local/lib/node/.npm/zappa/0.2.0beta/package/lib/../node_modules/jquery/dist/node-jquery.min.js'
    at Object.openSync (fs.js:221:18)
    at Object.readFileSync (fs.js:112:15)
    at Object.<anonymous> (/usr/local/lib/node/.npm/zappa/0.2.0beta/package/lib/zappa.js:19:15)
    at Object.<anonymous> (/usr/local/lib/node/.npm/zappa/0.2.0beta/package/lib/zappa.js:733:4)
    at Module._compile (module.js:402:26)
    at Object..js (module.js:408:10)
    at Module.load (module.js:334:31)
    at Function._load (module.js:293:12)
    at require (module.js:346:19)
    at Object.<anonymous> (/Users/harad/github/zappa/examples/hi.coffee:2:3)

Thanks in advance.

zappa shouldn't silently exit when running an "empty" file

At the moment if you make an "empty" app with some contents in public...

cd ~
mkdir empty_zappa_app
cd empty_zappa_app
touch app.coffee
mkdir public
echo "bar" > public/foo

... and then run zappa...

zappa app.coffee

...it will silently exit.

Instead it should run and serve static assets from public

If you want people to realise that their app is empty then display a warning but I believe what I have proposed is the expected behavior.

Problems adding middleware

use cookieParser (per Zappa's docs) does not work. The same is true for logger and session.

use express.cookieParser also fails. Only the form use express.cookieParser() works.

Heroku/foreman fail with process.env.PORT

I've been working on getting zappa into heroku, and I'm having trouble getting the port to work. I get the same error using foreman on my local machine as I do when I deploy the app to heroku.

If I specify a port like 5000 on my local machine foreman will run the app just fine, but heroku needs the app to grab the port using process.env.PORT to work (or maybe there's an alternate way to get the environment variable that i'm missing).

I thought that maybe process.env.PORT just wasn't working for some reason, but I got it to work using a plain express app.
I put process.env.PORT in console.log to see what it returns, and it shoots back a port number like nothing's wrong.

For a second I thought that maybe the switch statement at line 475 of zappa.coffee wasn't recognizing my variable port as a number. But that doesn't really make sense.
Because when I change port = process.env.PORT to port = #an_actual_number things work just fine.
That's as close as I got to figuring this out. I'm stumped.

Here's my test zappa app:

app = require 'zappa'

port = process.env.PORT

console.log 'process.env.PORT returns: ' + port

app port, ->
  get '/': 'hi'

and the Procfile:

web: coffee test.coffee

here's the error when I run foreman on my computer:

seth$ foreman start
12:57:16 web.1     | started with pid 486
12:57:18 web.1     | process.env.PORT returns: 5000
12:57:18 web.1     |    info  - socket.io started
12:57:18 web.1     | TypeError: Bad file descriptor argument
12:57:18 web.1     |     at HTTPServer.address (net.js:1127:10)
12:57:18 web.1     |     at /Users/seth/Sites/heroku_zappa/node_modules/zappa/lib/zappa.js:659:63
12:57:18 web.1     |     at Object.<anonymous> (/Users/seth/Sites/heroku_zappa/test.coffee:6:3)
12:57:18 web.1     |     at Object.<anonymous> (/Users/seth/Sites/heroku_zappa/test.coffee:11:4)
12:57:18 web.1     |     at Module._compile (module.js:404:26)
12:57:18 web.1     |     at Object.run (/usr/local/lib/node_modules/coffee-script/lib/coffee-script.js:62:19)
12:57:18 web.1     |     at /usr/local/lib/node_modules/coffee-script/lib/command.js:120:29
12:57:18 web.1     |     at /usr/local/lib/node_modules/coffee-script/lib/command.js:90:26
12:57:18 web.1     |     at [object Object].<anonymous> (fs.js:107:5)
12:57:18 web.1     |     at [object Object].emit (events.js:61:17)
12:57:18 web.1     | process terminated
12:57:18 system    | sending SIGTERM to all processes

and the error in the heroku logs:

2011-08-16T19:59:49+00:00 heroku[web.1]: State changed from created to starting
2011-08-16T19:59:54+00:00 heroku[web.1]: Starting process with command `coffee test.coffee`
2011-08-16T19:59:54+00:00 app[web.1]: process.env.PORT returns: 4474
2011-08-16T19:59:54+00:00 app[web.1]:    info  - socket.io started
2011-08-16T19:59:55+00:00 app[web.1]: TypeError: Bad file descriptor argument
2011-08-16T19:59:55+00:00 app[web.1]:     at HTTPServer.address (net.js:1127:10)
2011-08-16T19:59:55+00:00 app[web.1]:     at /app/node_modules/zappa/lib/zappa.js:659:63
2011-08-16T19:59:55+00:00 app[web.1]:     at Object.<anonymous> (/app/test.coffee:6:3)
2011-08-16T19:59:55+00:00 app[web.1]:     at Object.<anonymous> (/app/test.coffee:11:4)
2011-08-16T19:59:55+00:00 app[web.1]:     at Module._compile (module.js:404:26)
2011-08-16T19:59:55+00:00 app[web.1]:     at Object.run (/app/node_modules/coffee-script/lib/coffee-script.js:57:25)
2011-08-16T19:59:55+00:00 app[web.1]:     at /app/node_modules/coffee-script/lib/command.js:147:29
2011-08-16T19:59:55+00:00 app[web.1]:     at /app/node_modules/coffee-script/lib/command.js:115:26
2011-08-16T19:59:55+00:00 app[web.1]:     at [object Object].<anonymous> (fs.js:107:5)
2011-08-16T19:59:55+00:00 app[web.1]:     at [object Object].emit (events.js:61:17)
2011-08-16T19:59:55+00:00 heroku[web.1]: Process exited
2011-08-16T19:59:55+00:00 heroku[web.1]: State changed from starting to crashed

Thanks for taking a look.

Override default "use" modules for express

(This is something we discussed earlier in private emails.)

The idea is that one should be able to override the defaults for express's configuration (for example, maybe I don't want session management; or maybe I want to add more modules, etc.).

One possible implementation would be to modify "app" (I think) this way:
https://gist.github.com/767922
so that one can do for example:

app "default", (server) ->
  server.use express.staticProvider("#{process.cwd()}/public")
  server.use require('./bodyDecoder')() # my own version of bodyDecoder
  server.use express.cookieDecoder()
  # no session

Could not find module 'zappa'

I can't seem to get this to work. Seems like I'm missing something obvious. Suggestions?

$ zappa cuppa.coffee
Error: Cannot find module 'zappa'
    at loadModule (node.js:275:15)
    at require (node.js:411:14)
    at Object.<anonymous> (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:9:11)
    at Object.<anonymous> (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:139:4)


$ npm --version           
0.2.7-3
$ coffee --version        
CoffeeScript version 1.0.0
$ node --version          
v0.2.6

plugin API

Hi!
Is it possible to define global function like view in included coffeescript file?
example:
mongoose = require('mongoose').Mongoose
db = mongoose.connect 'mongodb://localhost/db'

model = (pair) ->
  for name, body of pair
    mongoose.model name, body
    pair[name] = db.model name
    def pair

autoreloading

Can Zappa do any kind of files autoreloading by default?

Autorestarters i've found are adapted for js files or analize files tree only once at start.

It would be nice if after every watched file change Zappa could reanalize "include"d dependencies or do it after each page refresh.

ability to configure socket.io transport options

Hi,
I'm trying to configure the socket.io transport order precedence as defined in the socket.io documentation here:

http://labs.learnboost.com/socket.io/

But I am at a loss as to when and how in the zappa framework one can configure the socket.io options. The ctor for the socket.io (new io.Socket(...)) gets called inside zappa and I'm not familiar with how to configure socket.io after the fact.

The main reason for this is that the current socket.io release breaks on the latest version of chrome (they changed their websocket implementation) and I must override socket.io to do xhr-polling rather than websockets.

Thanks.

zappa fails with the long "watch" flag (--watch)

Running...

zappa --watch FILE

...will cause zappa to hang indefinitely.

NFI why. I had a quick look but couldn't find a reason as to why this would occur. I doubt it's an issue in coffee-script/optparse but it's certainly possible.

I'll look into it later.

Multiple client-side socket events get confused

I'm running into trouble when defining multiple client-side functions to respond to different socket events. Here's a test case to reproduce. When pressing the button, I expect the log to show "First event" but it shows "Second event":

require('zappa') ->
  enable 'serve jquery'

  get '/': -> render 'new'

  at pressed: ->
    emit "first"

  client '/index.js': ->
    connect()
    at
      first: ->
        console.log "First event"
      second: ->
        console.log "Second event"

    $().ready ->
      $('button').click ->
        emit 'pressed'

  view layout: ->
    html ->
      head ->
        title "Test case"
        script src: '/zappa/jquery.js'
        script src: '/socket.io/socket.io.js'
        script src: '/zappa/zappa.js'
        script src: '/index.js'
      body ->
        @body

  view new: ->
    button "Push"

Expose socket.io "server"

Perhaps it can already be accessd from a zappa application but it's certainly escaped me after reading through the code and interrogating my app via REPL.

Basically it would be nice to access the socket.io "server" from an arbitrary location in the app without needing to resort to "def" hacks.

registry = {}
def registry: registry

get '/': -> 'Foo'

at connection: ->
  console.log "Connected: #{id}"
  broadcast 'connected', id: id

  registry.send = send

setTimeout(
  if registry.send
    registry.send 'foo'
, 1000)

As I mentioned, I'm convinced there's a way to do this already but it has alluded me...

cannot find module 'zappa'

I used NPM to install zappa. install happened without issue. created the cuppa.coffee and then ran zappa cuppa.coffee and I get this:

Error: Cannot find module 'zappa'
at Function._resolveFilename (module.js:320:11)
at Function._load (module.js:266:25)
at require (module.js:348:19)
at Object. (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:9:11)
at Object. (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:139:4)
at Module._compile (module.js:404:26)
at Object.run (/usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/coffee-script.js:55:19)
at /usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:115:29
at /usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:85:26
at [object Object]. (fs.js:107:5)

Here comes some versions for ya:
NPM: 0.3.18
Node: 0.4.5
zappa: Error: Cannot find module 'zappa'
at Function._resolveFilename (module.js:320:11)
at Function._load (module.js:266:25)
at require (module.js:348:19)
at Object. (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:9:11)
at Object. (/usr/local/lib/node/.npm/zappa/0.1.4/package/bin/zappa.coffee:139:4)
at Module._compile (module.js:404:26)
at Object.run (/usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/coffee-script.js:55:19)
at /usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:115:29
at /usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/command.js:85:26
at [object Object]. (fs.js:107:5)

I get that error with everything I do using zappa.

"coffee" not found.

I receive an error: ''' "coffee" not found. ''' whenever I try to run the zappa command with any arguments (or no arguments).

$ zappa
"coffee" not found.

Coffee-script is installed and is executing the zappa.coffee file. This error is actually being thrown from within the script itself. Specifically, it's on line 92 of zappa.coffee in the following snippet:

if args.length is 0
    puts parser.help() if options.help or argv.length is 0
    puts zappa.version if options.version
    process.exit()
else
    file = args[0]

path.exists file, (exists) ->
    if not exists
        puts "\"#{file}\" not found."
        process.exit -1

I originally encountered the problems with npm described in issue #27, so it's possible this is a continuation of my configuration woes. But I believe I have npm set up correctly now:

$ npm -v
1.0.3
$ npm list
<my local path>
├── [email protected] 
└─┬ [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  ├─┬ [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ └── [email protected] 
  ├─┬ [email protected] 
  │ ├── [email protected] 
  │ └─┬ [email protected] 
  │   ├── [email protected] 
  │   └── [email protected] 
  └── [email protected]

I apologize if I'm overlooking anything obvious, but I'm a coffee-script/node beginner and I don't quite follow what that path.exists function call is intended to do.

client method doesn't work

For some reason, @http_server appears to be undefined

$ cat z.coffee 
client index: ->
  alert 'hullo'

$ zappa z.coffee 

/home/hasenj/.node_libraries/.npm/zappa/0.1.3/package/lib/zappa.js:346
          return this.http_server.get("/" + k + ".js", function(req, res) {
                                  ^
TypeError: Cannot call method 'get' of undefined

(... stacktrace snipped ...)

Streaming able ?

Correct me if I'm wrong.

As far as I can tell CoffeeKup will never be able to stream the template results because to be able to return the results the top level function must return, and that happens only when all the template finished computing.

Is there anything that can be done to enable streaming support? Will CoffeeKup ever be able to stream results?

Integrate 'watch' option with isaacs node-supervisor

I'm really liking Zappa and thinking of converting my current Express / CoffeeScript project over to it. One thing stopping me is the watch support for restarting the server when the app coffee file changes.

Unless I'm reading the cli.coffee file in 0.1.5 incorrectly, the watch option doesn't accept an argument, just applies itself to the main app file. It would be cool to allow a watch filelist or dir to be specified.

Rather than implementing this yourself you might be able to leverage isaacs's fine node-supervisor utility, which is what I'm currently using for restarting my Express server in connection with a CoffeeScript directory watch.

Compatibility with Joyent No.de service & VMWare CloudFoundry

Joyent's No.de and VMWare's CloudFoundry node hosting services pull server settings from environmental variables. An example app written to work on a local developer box as well as the No.de service would be:

var http = require('http');

var server = http.createServer(function (req, res) {
  res.writeHead(200, { "Content-Type": "text/plain" })
  res.end("Hello world\n");
});

server.listen(process.env.PORT || 8001);

They both also assume that the main node entry point is a file named server.js (although other services may change this setting). To be more compatible with these services, it would be very helpful to:

  1. Allow any command line setting to also be configured via source code at runtime. This will accommodate these service's particular setups without forcing special command line build settings for deployment.
  2. Allow the compile flag to specify an output file name as well as the input file name.
  3. Allow via code, a way to specify require.paths.unshift settings to point to the correct server npm directories for these services (some of which are defined at runtime via environmental variables by these hosting environments). Currently with require('zappa') as the first line of the compiled app.js file, there is no way to bootstrap zappa usage without manually editing the compiled file to add the require.paths.unshift.

I think these services will be a popular way to deploy node services and supporting them will help with zappa adoption. Thanks.

websockets dont work

The server side part looks like it works fine. But anytime I try to do any websocket stuff client-side, node crashes and I get this

undefined:1

SyntaxError: Unexpected token ILLEGAL
at Object.parse (native)
at /usr/local/lib/node/.npm/zappa/0.1.2/package/lib/zappa.coffee:584:16
at [object Object]. (/usr/local/lib/node/.npm/zappa/0.1.2/package/lib/zappa.coffee:185:17)
at [object Object]. (/usr/local/lib/node/.npm/zappa/0.1.2/package/lib/zappa.coffee:4:36)
at [object Object].emit (events:27:15)
at [object Object]._onMessage (/usr/local/lib/node/.npm/socket.io/0.6.1/package/lib/socket.io/client.js:53:10)
at [object Object]._handle (/usr/local/lib/node/.npm/socket.io/0.6.1/package/lib/socket.io/transports/websocket.js:81:10)
at Stream. (/usr/local/lib/node/.npm/socket.io/0.6.1/package/lib/socket.io/transports/websocket.js:63:10)
at Stream.emit (events:27:15)
at IOWatcher.callback (net:484:33)

My code works fine when I use socket.io normally.

'in' operator broken when used in client script

To facilitate the in operator to check for list membership, CoffeeScript generates var __indexOf and puts this at the top of the JS output. When you use in in a client script in Zappa, the __indexOf bit doesn't get put into the client-side JS script, so in causes an error:

get '/': ->
  render 'index'

client 'test': ->
  foo = ['a', 'b']
  if 'a' in foo
    console.log 'Yes'

view index: ->
  script src: '/test.js'
  iframe src: '/test.js'

The script test.js is written with __indexOf undefined:

;(function () {
      var foo;
      foo = ['a', 'b'];
      if (__indexOf.call(foo, 'a') >= 0) {
        return console.log('Yes');
      }
    })();

Loading this page yields Uncaught ReferenceError: __indexOf is not defined.

Thanks a million for Zappa!

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.