With this in mind I decided to create a framework for the purpose of rapid RESTful API development. My aim was to provide a tool that allows developers to quickly set up REST endpoints that mirror the structure of their database schema, even if they have little experience with APIs. The result was rest-hapi, a RESTful API generator built around the hapi framework and mongoose ODM. rest-hapi automatically sets up CRUD endpoints based on mongoose models, which means all the developer has to do is set up their mongoose models and configure the server, and they’re good to go! On top of this, rest-hapi has built-in validation (using joi) and documentation (via hapi-swagger). Once the server is up and running, it can quickly and easily be tested and documented by viewing the swagger docs.
The other major hurdle rest-hapi attempts to resolve is the never ending decision of whether to choose SQL vs NoSQL for a database. Generally speaking, developers choose SQL/relational databases for the structural advantages they provide, since most projects naturally contain some sort of relational structure within their data, while NoSQL databases are chosen due to their flexibility and scalability. rest-hapi attempts to combine the best of both worlds by using a NoSQL database (MongoDB) as its foundation, while also allowing relational structure to easily be defined within the model definitions. When model associations are defined, rest-hapi automatically generates association endpoints alongside the CRUD endpoints.
While rest-hapi doesn’t provide an end-all solution to API development, I do believe it will be a great tool for developers that want to quickly set up an API to test their latest app idea. Right now the project is still in it’s infancy, but eventually I hope it will reach a point where it could be used as a foundation for production level projects. Please take some time to check it out! If you have any feedback, feel free to open an issue in GitHub, or if you want to get in touch you can reach me at Twitter, Facebook, or LinkedIn, or email me at email@example.com. Thanks for reading!
Hacker Noon is how hackers start their afternoons. We’re a part of the @AMI family. We are now accepting submissions and happy to discuss advertising & sponsorship opportunities.
If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!