punkave / zoltar

Zoltar sees all! Zoltar launches your node-powered sites on demand when you access them by their actual names. No more "node app", no more "http://localhost:3000". Also provides a web console to view the output and start, stop and restart apps.
MIT License
8 stars 0 forks source link

Allow for start scripts other than app.js #7

Closed gsf closed 10 years ago

gsf commented 10 years ago

Many non-express Node apps use server.js as the main executable (that's the default for npm start). We could take several approaches to account for this:

  1. Leave it as is and make all projects using node-dev-proxy provide an app.js (at least as a symlink to server.js or whatever other start script). Easy enough for any app developer to do but kind of an annoying barrier to using node-dev-proxy.
  2. Set up proxy-wide configuration. Wouldn't take much development time but doesn't address the likely scenario where a heterogeneous mix of app.js and server.js sites are proxied.
  3. Rely on npm start. This would require any sites using something other than server.js to define a "start" script in package.json. And it wouldn't allow for switching the "node" executable out for nodemon or node-dev.
  4. Use server.js if app.js is missing. This would solve the immediate problem but still doesn't provide any configuration for start scripts other than app.js and server.js.
  5. Rely on "main" in each site's package.json (falling back to app.js or server.js if it isn't there). Since most Node projects define "main", I think this solution allows the most flexibility per proxied app while putting the least burden on the developer.
boutell commented 10 years ago

Gabriel, these are really good points, thanks.

I am not so sure that most projects define "main." The projects we can't see are all the "client projects" on which people will be most likely to actually use node-dev-proxy, because they are websites and node-dev-proxy is really convenient for accessing websites, and not really intended for running anything with command line arguments.

The apostrophe sandbox specifies "main" correctly, so all of our projects born from it probably do too, but I'm willing to bet lots of projects get this wrong or have no package.json yet at a certain stage of development.

How about:

  1. Look for what's in main
  2. Look at a defined list of fallbacks, which can be changed via configuration: server.js, app.js, index.js
  3. Give up (:
gsf commented 10 years ago

Sounds like a plan I can get behind!