5 ms·
To be honest, this doesn't look like much of a web framework. The examples show views being built up using string concatenation... reminds of my pre-templating
by kainosnoema 15y ago
To be honest, this doesn't look like much of a web framework. The examples show views being built up using string concatenation... reminds of my pre-templating days building snippets for jQuery.
Really though, everything shown can be easily replicated with a bit of Connect middleware, and it'd be cleaner. I don't see the point?
- hello_moto 15y agoNode.js is the new hotness, you've gotta write a framework (as opposed to tools that analyze JS code and point out potential pitfalls and bugs, or tools to build and deploy complex JS solutions, or tools/framework that support better unit-testing for JS both server and cliend-side) to get street-creds these days.
- skeptical 15y agoI would go as far as saying that it does not offer much more than what you can do with the http module. But if you take away built-in template engines, orm, active reccord and an CRUD generators (both for web forms and APIs), the same applies to 90% of the frameworks out there. I work with pretty messy code bases and every other week find myself wondering if using a framework did really helped more than it introduced unnecessary code.
- mjijackson 15y agoThat's like saying that WSGI/Rack don't do anything more for Python/Ruby than their respective HTTP libraries. When you understand the rationale behind those libraries you'll understand Strata.
- skeptical 15y agoNo. Node.js itself is an event machine, node's http module is nothing but a particular plug-able even handler framework. That is not the same writting an application in python that uses the http library. The latest requires considerably more work, the prior is much simpler.
- bronson 15y agoIt lets you choose whatever ORM (Mongoose!), templating (Weld!), and CRUD routing you want. It's like Rack or maybe Sinatra, but definitely not Rails. And it's much nicer to use than the http module: layerable middleware, streaming responses, routing...
- troyk 15y agoGranted I blazed through the docs and am not a node expert, but for a streaming web framework I could not find a reference to streaming responses. It is very Rackish, all examples I found point to calling callback(200, {}, "Hello world!"); What I don't get, is you have to fight with Rack to get anything close to async, yet here comes a web framework for an async environment modeled after Rack, go figure. I assume (meaning I'm about to make an ass out of u & an ass out of me) the answer is to pass a stream in place of the "Hello world!" string, but that would cause hell with any middleware expecting a completed response.
- mjijackson 15y agoThe Strata spec states that a body may be either a string or a stream. All Strata middleware that needs to modify the body in some way must account for this. It's not difficult to do a "if (typeof body == 'string')". Strata borrows many concepts from Rack, but not the synchronous part. Instead of expecting your app to return something, Strata gives you a callback that you can use to serve the response when you're ready. I admit the manual could probably give a better example of streaming a response. For now, check out the static file serving middleware (https://github.com/mjijackson/strata/tree/master/lib/static.js https://github.com/mjijackson/strata/tree/master/lib/static....). You'll see that the response body is simply a readable stream to the file on disk.
- troyk 15y agoThanks, I get it now. Think I'll go play some SSE with it http://www.igvita.com/2011/08/26/server-sent-event-notifications-with-html5/ http://www.igvita.com/2011/08/26/server-sent-event-notificat...
- mjijackson 15y agoThe examples use string concatenation for the sake of simplicity. Strata doesn't attempt to tie you to any particular templating library because everyone has their own preferences and there are so many of them out there. For an example of using ejs with Strata, take a look at the source to the Strata website: https://github.com/mjijackson/stratajs.org https://github.com/mjijackson/stratajs.org
- ctide 15y agoConnect middleware has never been especially clean for me. Every app I end up working on, we slowly grow this hideous mess of middleware that starts off like: https://github.com/LockerProject/Locker/blob/master/Ops/webservice.js#L38-56 https://github.com/LockerProject/Locker/blob/master/Ops/webs... And tends to end with around 40 lines of checking URLs and other various bits of information to know which middleware can be chained in, and in which order that doesn't cause them to conflict with one another. If Strata can solve this mess, then it's definitely a step up in my opinion.