Best way to set an API server using Node.js and Postgres? - node.js

I'm new in Node.js. I'm trying to find out and learn which is the best way to set an Api Server, just for CRUD (Create, Read, Update and Delete) requests.
I've being looking around the different server frameworks that are normally used with Node.js:
Express
Restify
Hapi
I'm also using the node-postgres library already connecting to the database and making queries, but I haven't found a good guide or example using either of the previous frameworks to set an Api Server with PostgreSQL.
I'd be very thankful is someone could point me to the right direction or show me a basic example.
Thank you

Hapi has the best performance. Otherwise I hope this can help you:
http://blog.newrelic.com/2014/08/15/node-js-frameworks-hapi-js-restify-geddy
http://blog.nodeknockout.com/post/34571027029/making-an-api-happy-with-hapi
http://blog.modulus.io/nodejs-and-hapi-create-rest-api

Related

What potholes are there Using Graphql with RethinkDb?

As I understand it's possible graphql with rethinkdb. You can use graphql to query really any data set as its just the middleware really. What issues do I need to watch out for in this implementation? Server will be node.js in my case.
Documentation / examples of others doing this seam lacking.
I'm using GraphQL together with RethinkDb and don't see any particular problems in using them together compared to an implementation of a rest api or using mongo etc.
Here are two github projects using GraphQL and RethinkDb (the first one is more lightweight):
Isomorphic Material Relay Starter Kit
meatier

ActionHero.js Framework with Oracle database persistence

I am quite new working with nodejs, I need to make a REST API that can work with websocket. I was searching for a framework that I could work with, I found actionhero.js, I think that can fit my needs.
But I see a little problem with this framework, that I can't find information about how can I make it work with oracle database, I will be really grateful if any of you can give me a light on how can I make it work this framework with a Oracle Database, or suggest me a framework based on REST API that can fit my needs.
Thank you.
Actionhero is, as you point out, a REST API framework. It doesn't include any database drivers (other than for redis, which it uses for cluster communication). You can easily ad support for any database you like in an initializer.
There are also plugins which add database support. For example, the ah-sequelize-plugin adds support for the Sequelize ORM, probably the most popular node.js ORM. Sequelize doesn't support the Oracle DB out of the box (very few things do), but there exist drivers you can use: https://github.com/adeo-proxideco/sequelize-oracle

Express.js and Neo4j

I have seen alot of examples of how to integrate express.js and mongodb. Does anyone know a good way to integrate neo4j and express.js?
I have been playing around with node-neo4j and I am able to return cypher queries to the terminal. However, I am confused as to how to post the cypher query, in json format, to the local host.
Thanks for your help.
In order to reply simply to your question, there is an express module for Neo4j, here :
http://expressjs.com/guide/database-integration.html#neo4j
It will remove you the burden to format the json correctly for preparing the statements.
Repository is here if you want to see how it is used inside :
https://github.com/hacksparrow/apoc
Maybe you can contribute to it, for the quick look I did, I see that there is no support for 2.2 auth extension, so you may want to make a PullRequest in order to improve the library.

Using dc.js with node.js

Is it possible to use dc.js with node.js, and if so how? I would like to provide an example, but it's hard to see how to start on this, and no working examples seem to be available online.
In short, yes.
I have implemented a full fledged app using nodejs and dc while the document store was mongo. The nodejs server is used for fetching the data from mongo db and serving it as api. Dc.js then uses this data for rendering charts.
I will write a blog post about it and post it in a couple of days. In the meantime do let me know if you have any more queries.
Updated:
Here is the link to the blog post.Do share if you find it useful.
https://anmolkoul.wordpress.com/2015/06/05/interactive-data-visualization-using-d3-js-dc-js-nodejs-and-mongodb/

derbyjs for REST API

First of all, I have seen this question: How to best create a RESTful API in Node.js and it has pointed me towards mers, which has been a great help.
But I have also been reading a lot of good things about derbyjs and it does look really interesting.
So my questions, does it make sense to use derbyjs for ceating a REST API (real-time features might be useful in the future, but not a 100% certain at this pont.)? And is it any better or worse than mers?
I am really grateful for any help.
Edit:
If anyone is interested, decided now to use sails.js: http://sailsjs.org/
The strength of Derby is that the same views (i.e. rendering templates into HTML) can be executed on the client as well as on the server. So for building a webapp, you won't have to explicitly code a REST API and then use it from the client-side JavaScript, instead you just write your views and Derby does the rest.
So if you're looking into making a REST API only (as your question states) and no HTML, there is no advantage in using Derby. It's the wrong tool for the job.
It depends on what you're looking for exactly. Derby.js is built on top of Express.js which has excellent support for creating a REST API. This also means that anything you can do in Express, you could also do in Derby. If you want real-time features, and the ability to build out a REST API, Derby.js is an excellent choice. It's also one of the reasons that people recommend Derby over something like Meteor (currently Meteor does not have support for REST endpoints, but it will hopefully in the future so also something you might want to keep your eye on, if you're in the market for real-time framework). However, if you're not looking for a node framework with an emphasis on real-time functionality, Derby is not the right choice. I would however recommend looking into Express.js to build a REST API. We use it currently for that purpose and it works really well. There are also a number of libraries and packages that play nicely with Express, so in the future if your needs change, it's easy to find something that works well with Express.
Anyway, I would recommend checking out some basic tutorials for how to create a REST API in Express because once you're able to successfully do that, adding some of the real-time features of Derby.js is fairly straightforward.
Basic tutorial on creating a REST API in Express.
http://coenraets.org/blog/2012/10/creating-a-rest-api-using-node-js-express-and-mongodb/

Resources