4 comments

[ 2.2 ms ] story [ 20.3 ms ] thread
Take a look at our newly released express.js-based, "swagger-matic", server runtime for Node.js.

BlueOak Server is "swagger-matic" because it maximizes the value of your Swagger API by using it to drive runtime behavior: It loads your Swagger API, connects the paths it defines to your implementation code, exposes that API to the network, and validates that every request is well-formed per that API.

We've got a lot of value from using it on our projects, and hope you will too, or, at least your criticism will help us make it better for us :-)

We've built something similar with RAML in Python. It's called Ramses: https://github.com/ramses-tech/ramses

I like the "single source of truth" concept. It makes a lot of sense IMO.

Does it generate the handlers for you or do you have to write them by hand and hook to the Swagger definition?

You write your own handler and use the combination of the `operationId` field and an additional `x-handler` field to location your function. You can think of it like this: `pathHandler = require('${project-root}/handlers/${x-handler}').${operationId}`

The server provides dependency injection so that when you implement your handler-level function it can access several re-usable services to do the "real work". Generally my handlers are limited to getting the parameters off the request, passing them on to a (chain of) service(s) and getting the response back out to the client.

I hope the wiki has some good additional info if you're interested: https://github.com/blueoakjs/blueoak-server/wiki

I really like the "single source of truth" too.

How much does Ramses integrate with the data source "automatically"? Is it like StrongLoop/LoopBack?

We've found that for most of our projects we're not connecting directly to a database, but instead trying to present an (mobile or web) app-specific API that abstracts/unifies/focusses the many data sources and services that may be needed.

For example, one recent project involved data coming from some old SOAP services, new HTTP (but not exactly RESTful) endpoints, and several public APIs too.