
LoopBack, a new Node.js framework by StrongLoop - linhmtran168
http://loopback.io
======
Rezo
Nitpick, but the "GET /people/{id}/exists" in the example to check if the
instance exists is a bit weird, would suggest "HEAD /people/{id}" for this
type of operation.

~~~
Goopplesoft
Actually the resource should typically 404 to indicate it doesn't exists
(generally speaking for http apis).

~~~
euank
Yeah, the HEAD or GET should return a 404 on not existence; however, the HEAD
also won't return data which is the point. GET implies that you have need of
the returned data (presumably all the properties of that person). GET is for
"it exists AND I want to know about it". HEAD really is more appropriate here.

~~~
enjoyjava
HEAD is a good fit. We'll add support for that. Please open github issues to
help us track the feature requests or bug fixes at
[https://github.com/strongloop/loopback/issues](https://github.com/strongloop/loopback/issues).

------
hardwaresofton
As someone that is in the middle of writing a nodejs thin API layer, working
with express-resource, this looks really amazing to me. It looks like I can
stop worrying about writing middle thin-API code, and focus on front-end
manipulation of a stable middle/backend

However, the scale of this really worries me. I really like small tools (flask
over django, knockoutjs over angular sometimes,etc) -- and this seems like a
LOT to take in to a project, sort of hoping it all just works...

Also, why is Postgres support not more prominently stated? It's there, but I
had to search for it. And on that note, why is JSON stored in postgres as a
varchar? why not use the postgres JSON type (compatibility reasons, maybe?)

~~~
rmgraham
Postgres almost warrants its own non-generic ORM. That would actually be kinda
cool.

~~~
hardwaresofton
If I understand your comment right, are you looking for something like this:

[http://bookshelfjs.org/](http://bookshelfjs.org/)

I haven't done much work with a relational DB from nodejs (I've just used
nosql databases that offered relational functionality -- i.e. rethinkdb), but
this seems like as good a thing as any for ORM-y stuff with Postgres

~~~
whatthemick
There's also Sequelize ([http://sequelizejs.com/](http://sequelizejs.com/))
which is increasing its focus on Postgres specific features.

------
ddispaltro
I feel like you should give a little shout out to the folks over at Wordnik
[https://github.com/wordnik/swagger-ui](https://github.com/wordnik/swagger-ui)
for putting together such an awesome API browser.

------
distracteddev90
This looks amazing, and the StrongLoop team is chalked full of some great
Node.js developers.

But for some reason I'm still worried about using it as the backbone for an
enterprise scale application; it almost does too much. Perhaps I'm just too
averse to this amount of "magic" in any piece of infrastructure due to my
Django days.

The code is open, but you're not just buying into a single module with a
single purpose -- this is an entire architecture. I guess in such cases, worry
is warranted before accepted it as the backbone of your company/application.

~~~
duncanawoods
Off-topic note on "chalked full" \- you probably mean chock-full, an old
phrase probably derived from the word "choke". I was entertained trying to
imagine what a chalk filled team might be though :)

------
sergiotapia
Wow, I'm building something a bit similar in the Go area:
[https://github.com/sergiotapia/paprika](https://github.com/sergiotapia/paprika)

Nice to know it's a good idea that a lot of people will find useful. :)
Granted in it's current vision Paprika won't handle authentication.

It's basically an API server in-a-can. Defined your structs, set up your .toml
database configuration and paprika.Start("3000") on a port.

~~~
drdaeman
I've seen ton of "expose DB as REST-like API" libraries in various languages,
and even tried (unsuccessfully) to write one myself. I'd say just exposing
model is trivial, even when coupled with content-type negotiation.
Subjectively, the hardest part is permissions (operation, row and field-level
ones) and making them play nice with REST and HTTP concepts (like ETags).

~~~
camus2
etags , hateoas,hypermedia... definetly the hard part,along with security.
Getting an API right is hard work.Still search for the holy grail...

~~~
enjoyjava
Agree. We try to solve the problems progressively. The connected model support
is a foundation to those features. See
[http://strongloop.com/strongblog/defining-and-mapping-
data-r...](http://strongloop.com/strongblog/defining-and-mapping-data-
relations-with-loopback-connected-models). Basically, we build models that
relate to each other, partition the data graph with links, and expose them as
REST APIs that can be used to navigate and aggregate the information from
various data sources.

------
sahat
Nice landing page, I'll give them credit for that. But why would I want to use
this instead of Express or Restler?

~~~
enjoyjava
LoopBack is built on top of express. You can use express routing and
middleware with LoopBack as is.

Express allows you to expose HTTP endpoints as APIs but it doesn't facilitate
the quest to build/aggregate/protect/document APIs that interacts with various
backend systems, such as DBs, Cloud services, and internal REST/SOAP APIs.
LoopBack is positioned to be a fully-fledged API server with SDKs for JS, iOS,
and Android.

------
balls187
This is slick, especially the API explorer, but my biggest gripe about these
orm's is that once you get past the very basic CRUD, you need to execute
custom sql.

Does it support custom DB types?

For example, I want my primary keys to be bigint on Mysql, and not have to
override the underlying dbdriver to do the mapping. I'd prefer to set the
appropriate dbtype in the model, and have the driver pass it along directly.

Also does it support dbdriver level SQL query execution?

I have custom aggregation query across a self join, and that's not easily
represented with static methods on a model.

Today I use node-orm2, with a custom SQL script that updates the identity
columns to be bigints, and it supports executing raw sql queries (with some
basic parameter sanitizing).

~~~
lobster_johnson
Has the same problem using Bookshelf (which built on Knex). The query language
breaks down almost immediarely. Need to use PostGIS primitives? Awkward. Need
to perform aggregate functions with group by, or add dynamically computed
columns to the select? Impossible. Subqueries in the select? Nope. Need to
order by a function? Impossible, too.

These libraries fail because they are not designed around a logical expression
language (unlike Ruby's ARel, a very nice SQL building library that forms the
underpinnings of ActiveRecord). You need to be able to programmatically build
expressions as an AST which still preserving SQL language rules and avoid
exposing yourself to injection.

~~~
akbar501
> The query language breaks down almost immediarely.

Agreed. We dropped an ORM completely and use SQL in functions (aka stored
procedures). For models we use plain JS objects and for validation we use Joi
([https://github.com/spumko/joi](https://github.com/spumko/joi)) from Walmart
Labs.

Eliminating an ORM has been freeing. We did have to invest in upgrading our
team's SQL skills, but we no longer run into limitations of an abstraction
layer. Our queries are faster as there are fewer layers. Now that we're up to
speed on SQL we find it to be expressive for our data access needs.

------
segphault
For node-based API backends, I've been using Sails.js or Deployd. In addition
to providing automatic RESTful CRUD APIs for your data models, both Sails and
Deployd also provide WebSocket interfaces that make it really easy to support
real-time capabilities without doing any extra work. It doesn't look like
LoopBack does that.

I've been particularly happy with Sails.js as the backend framework for my
single-page web apps. I get rid of the Sails view system and use it solely as
an API backend. The current 0.10 beta, which adds support for associations in
data models, is really nice.

~~~
angersock
I've been considering using Sails to redo a simple RoR project--mostly to help
decrease the number of languages floating around in the project.

Any thoughts/gotchas from your experience with it?

~~~
segphault
* The Sails ORM (which is called Waterline) is very light and simple, but it doesn't have the maturity or the same degree of expressive power that you get with ActiveRecord. Associations were recently added and the query system doesn't really let you take advantage of them quite yet.

* There are also subtle differences in behavior that emerge when you use Waterline with different database adapters, so you really need to develop against the same DB adapter that you intend to use in production.

* When you need to customize the behavior of the CRUD methods that Sails gives you by default (like if you need to transform some parameters passed in by the user in the create method), it is often cleaner and easier to do it by applying custom policy methods rather than overriding the actual CRUD method in the controller.

* For a new Sails project, you probably want to start with the new version 0.10 even though it hasn't been officially released yet.

Those are the points that first come to mind. Despite the limitations, I've
found it to be a pretty compelling framework. And it's very actively
developed, so a lot of the deficiencies are being corrected.

~~~
angersock
Thank you!

------
OlavHN
Cool! Handling CRUD APIs and authentication desperately needs a flexible
library! I can't seem to find any kind of versioning, changelist, etc to
facilitate reactive clients tho. Is it lacking or am I not seeing it?

Edit: Whey!
[http://docs.strongloop.com/display/DOC/Synchronization](http://docs.strongloop.com/display/DOC/Synchronization)

------
kristream
Can you explain about Mongodb support? Does it use mongoose behind? What about
if I have my own mongoose model, can I still continue with same?

I did look at loopback a while ago, it was appeared like a parse.com kind of
API you host on your own infrastructures. I will reread the documentation
again to see if any more clarity on mongodb side.

------
ChrisGaudreau
This framework feels kind of like Rails for REST APIs, but not in a bad way. I
really like it so far.

------
centrinoblue
I really like the Angular sdk. I find it really speeds up the process of
spinning up a new project

~~~
dashby3000
Thanks! Please also check out [http://strongloop.com/strongblog/full-stack-
javascript-isomo...](http://strongloop.com/strongblog/full-stack-javascript-
isomorphic-loopback-browse/). LoopBack model APIs can be run inside the
browsers too and they are backed by local storage and/or remote data sources.
Isomorphic model!

------
imslavko
Spent a minute in confusion of the name: LoopBack. Before I have seen another
dev tool/service with exact same domain but it was about recording the
interactions history for your iOS app.

Then it occurred to me the iOS rewind service is looKback.io, so close :)

------
hippich
Looks really awesome. Building my REST app with Baucis right now and finding
ACL built-in is really nice!

Any plans for using Express > 4.x? More and more stuff is targeting Express
4.x these days.

~~~
wprl
Baucis takes the approach that monolithic frameworks are more costly in time
and resources to build software with in all but the short term, and only then
sometimes. Long live small libraries!

Putting that conversation aside, I'd be very interested to know what
advantages there are for you in having ACL built-in vs. using one of the ACL
middleware modules that are available through npm.

William Riley-Land (Author of baucis)

~~~
hippich
Requirements for ACL for json fetching/saving and regular rest endpoints are a
bit different, so I couldn't find exact fit so far. In most cases you have to
define a function, which become too verbose with very little re-usability.

That been said, there are a lot of node.js modules out there and I could
simply miss right one. If you could point to a couple you think might play
very well with baucis - I would really love it.

In general most of rest/mvc frameworks our there miss this part entirely. I am
ok with acl being not part of particular framework as long as there is at
least one 'blessed' combination to use.

= pavel karoukin - author of baucis-access plugin :)

~~~
wprl
Oh hey, Pavel :)

What're your "killer features" that are lacking for ACL in Node in your
experience?

I'm becoming severely intrigued by the idea of using specialized proxy servers
for applications like this…

------
kudu
This looks pretty cool! I'll be sure to give it a try. It's a shame that
there's no support for Ember though.

~~~
bajtos
Since LoopBack exposes a REST-like API, you should be able to use Ember
modules in your client:

[http://emberjs.com/guides/models/the-rest-
adapter/](http://emberjs.com/guides/models/the-rest-adapter/)
[http://emberjs.com/api/data/classes/DS.RESTAdapter.html](http://emberjs.com/api/data/classes/DS.RESTAdapter.html)

------
joeyspn
Gonna give this a go for my next project, I just hope they implement real-time
capabilities like Sails/Deployd ASAP

------
cnp
This definitely appears to be the most in-depth and fleshed out Node framework
yet. Fantastic docs, too!

Awesome work.

------
nls
Looks great, but what about validation for the models? Didn't see that
mentioned anywhere.

------
shubhra51
Love the SOAP connector and storage service. Looking for docs around the
offline sync support

------
logotype
Hehe, I owned that domain, loopback.io, a year or two ago. I didn't renew it
obviously.

~~~
logotype
OTOH I still have monospace.io which is a pretty nice domain. Anyone
interested?

~~~
lobster_johnson
That would be great for a personal side project of mine, can you email me?
Email address on my profile page. Thanks!

------
ykumar6
This is very impressive.

------
Kinnard
What's the Omega in the terminal??

~~~
sudont
I'm guessing it's just his prompt. The Node/JS community has a bit of thing
for using unicode characters everywhere.

Case in point:

[https://github.com/mbostock/d3/blob/c247e1626118de41b3d40e2a...](https://github.com/mbostock/d3/blob/c247e1626118de41b3d40e2a711354f76e004343/src/geo/conic.js)

------
heroprotagonist
I thought that LoopBack appeared promising until I came across their astroturf
campaigns on reddit. That completely turned me off to them.

~~~
millstone
Can you please provide more information? What campaigns and how did you
discover them?

------
camus2
hmm, new? no,good for rest rad yes.

But we still need a nodejs framework for good old html apps with a strong view
layer (e.g. forms...).It definetly doesnt exist in nodejs space.

~~~
cjbprime
Seen sails.js? How's it different from what you're looking for?

------
zerr
Didn't we all agree that JavaScript is a bad language for development in
large? So why won't we switch to e.g. TypeScript?

