Automatically Generate REST API For Your Database Without Coding
Ever thought about finding a way to skip all the hassle of creating an API when creating a MEAN app? Here is the solution.
MEAN (MongoDB,ExpressJS,AngularJS,NodeJS) stack has become one of the most popular ways of building a website today because it lets you create a dynamic,attractive website within a few hours. If you are building a Node app,creating a REST API will be one of the hectic tasks that you have to do to connect your front-end to back-end.
Today I am going to tell you about a framework which completely handle this task for us.It is the LoopBack framework which is maintained by IBM StrongLoop.
What is LoopBack?
LoopBack is an enterprise-ready,open source NodeJS framework which is built on ExpressJS. LoopBack allows creating REST APIs from your database with a few or no lines of code. You can either create a database or use an existing database with LoopBack.It will either explore your database(if it is an existing database) or create a new database and automatically generate a REST API for your database without the trouble of the developer having to do it by himself. Awesome Right? Who doesn’t like a free API Generator which takes care of a big part of your work.
LoopBack Features
- Comes with an easy-to-use CLI
- Create models with absolutely no effort
- Built-in API explorer (I see this as one of the top features of Loopback framework)
- Define Relationships
- Built-in role based access controls
- Built-in oAuth user and registration models
- Easily connect to any database
Supported Databases
- MySQL
- Oracle
- PostgresSQL
- Microsoft SQL
- MongoDB
and many more databases and REST services
How to connect to your database?
LoopBack uses the concept of “connectors” to connect the database with your LoopBack application.There are different connectors for different database types and by using them you can easily connect with your database.
The role of using connectors come in handy if you ever want to change your database engine.If the API was written by yourself, you will have to write new queries and build a whole new API. But with LoopBack connectors, you only have to change the connector and the API will stay the same.
On my next article I will tell you about how to generate a REST API with LoopBack using LoopBack CLI. Be ready to stop creating APIs by yourself and let it generate automatically.
Till then,
Happy Coding !
References: https://loopback.io/