{"id":2234,"date":"2018-05-30T05:33:45","date_gmt":"2018-05-30T09:33:45","guid":{"rendered":"https:\/\/www.danielpradilla.info\/blog\/?p=2234"},"modified":"2018-05-30T05:33:45","modified_gmt":"2018-05-30T09:33:45","slug":"how-to-build-an-api-for-sap-hana-using-strongloop-loopback","status":"publish","type":"post","link":"https:\/\/www.danielpradilla.info\/blog\/how-to-build-an-api-for-sap-hana-using-strongloop-loopback\/","title":{"rendered":"How to build an API for SAP HANA using strongloop\/loopback"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2237\" data-permalink=\"https:\/\/www.danielpradilla.info\/blog\/how-to-build-an-api-for-sap-hana-using-strongloop-loopback\/saphana\/\" data-orig-file=\"https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/saphana.jpg\" data-orig-size=\"897,172\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"saphana\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/saphana.jpg\" class=\"aligncenter size-full wp-image-2237\" src=\"https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/saphana.jpg\" alt=\"\" width=\"897\" height=\"172\" srcset=\"https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/saphana.jpg 897w, https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/saphana-300x58.jpg 300w, https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/saphana-768x147.jpg 768w\" sizes=\"auto, (max-width: 897px) 100vw, 897px\" \/><\/p>\n<p>One of the aspects I like the most about SAP HANA is the cloud app development environment that allows you to <a href=\"https:\/\/open.sap.com\/courses\/mobile2\">quickly put together a data-entry app using Fiori<\/a>.<\/p>\n<p>Recently, I wanted to build a small JavaScript app for data querying and entry using the awesome <a href=\"https:\/\/www.ag-grid.com\/ag-grid-tutorials\/\">ag-grid<\/a>. The data was in SAP HANA but the prospect of building and testing a secure API was quite daunting (is it worth it? How long is it going to take? Who&#8217;s going to maintain it?) It was actually easier to switch to MongoDB, use Express or <a href=\"https:\/\/github.com\/parse-community\/parse-server\">Parse<\/a> and add an ETL process to sync the databases. Wouldn&#8217;t it be great if there was a way to create some sort of automatic API through configuration?<\/p>\n<p>There is.<\/p>\n<p>The Loopback component of <a href=\"https:\/\/strongloop.com\/\">Strongloop<\/a> offers the possibility to quickly create secure APIs for CRUD operations against MySQL, Postgres, Oracle and other databases. In many cases, it allows you to completely bypass the development of boring and \u2013commoditized\u2013 backend stuff. Using a convention over configuration approach, you can create endppoints for each of your tables in a matter of minutes.<\/p>\n<p>But, can it connect to SAP HANA?<\/p>\n<p>I googled and found a <a href=\"https:\/\/github.com\/jensonzhao\/loopback-connector-saphana\">connector for HANA<\/a><\/p>\n<p>The best way to set this up is to containerize the solution: create a docker container with an installation of strongloop and link a directory in the host machine to the working directory of the container, that way you keep the configuration outside of the container to quickly modify it, and you can quickly switch or upgrade the container.<\/p>\n<p>I started from <a href=\"https:\/\/hub.docker.com\/_\/node\/\">node official image<\/a>, but you can start from the <a href=\"https:\/\/hub.docker.com\/r\/strongloop\/node\/\">strongloop official image<\/a>, and created my own, which you can use. Here is <a href=\"https:\/\/hub.docker.com\/r\/danielpradilla\/loopback\/\">a link to my image<\/a>.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nFROM node\r\n\r\nMAINTAINER Daniel Pradilla &lt;info@danielpradilla.info&gt;\r\n\r\nRUN npm -g config set user root\r\n\r\nRUN npm install -g --unsafe-perm strongloop \r\n\r\nRUN npm install loopback-datasource-juggler\r\n\r\nRUN npm install loopback-connector-saphana\r\n\r\nWORKDIR \/app\r\nEXPOSE 3000\r\n<\/pre>\n<p>Once you start the container, you need to create a connection to SAP HANA<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ndocker run --name loopback -p 3000:3000 -v `pwd`:\/app\/ -t -i danielpradilla\/loopback slc loopback:datasource\r\n<\/pre>\n<p>Then, you have to edit your server\/datasources.json file and manually specify the schema name (This is something that you don&#8217;t need to do with other databases, and you may get stuck on a table not found error if you don&#8217;t do it)<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n{\r\n  &quot;db&quot;: {\r\n    &quot;name&quot;: &quot;db&quot;,\r\n    &quot;connector&quot;: &quot;memory&quot;\r\n  },\r\n  &quot;hana&quot;: {\r\n    &quot;host&quot;: &quot;my_server_address&quot;,\r\n    &quot;port&quot;: my_server_port,\r\n    &quot;database&quot;: &quot;MY_DATABASE_NAME&quot;,\r\n    &quot;name&quot;: &quot;hana&quot;,\r\n    &quot;user&quot;: &quot;my_HANA_user&quot;,\r\n    &quot;password&quot;: &quot;my_hana_password&quot;,\r\n    &quot;schema&quot;: &quot;MY_SCHEMA_NAME&quot;,\r\n    &quot;connector&quot;: &quot;saphana&quot;\r\n  }\r\n}\r\n<\/pre>\n<p>Then you create an endpoint to the table using the wizard<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ndocker run --name loopback -p 3000:3000 -v `pwd`:\/app\/ -t -i danielpradilla\/loopback slc loopback:model\r\n<\/pre>\n<p>Or using arc by running the API interface<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2236\" data-permalink=\"https:\/\/www.danielpradilla.info\/blog\/how-to-build-an-api-for-sap-hana-using-strongloop-loopback\/loopback-arc\/\" data-orig-file=\"https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/loopback-arc.png\" data-orig-size=\"1000,619\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"loopback-arc\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/loopback-arc.png\" class=\"aligncenter size-full wp-image-2236\" src=\"https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/loopback-arc.png\" alt=\"\" width=\"1000\" height=\"619\" srcset=\"https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/loopback-arc.png 1000w, https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/loopback-arc-300x186.png 300w, https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/loopback-arc-768x475.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ndocker run --name loopback -p 3000:3000 -v `pwd`:\/app\/ -t -i danielpradilla\/loopback slc arc\r\n<\/pre>\n<p>And after that, you are ready to experience the awesomeness of having all the API endpoints created for you.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ndocker run --name loopback -p 3000:3000 -v `pwd`:\/app\/ -t -i danielpradilla\/loopback slc run .\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2235\" data-permalink=\"https:\/\/www.danielpradilla.info\/blog\/how-to-build-an-api-for-sap-hana-using-strongloop-loopback\/loopback-api-overview\/\" data-orig-file=\"https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/loopback-api-overview.png\" data-orig-size=\"1000,760\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"loopback-api-overview\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/loopback-api-overview.png\" class=\"aligncenter size-full wp-image-2235\" src=\"https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/loopback-api-overview.png\" alt=\"\" width=\"1000\" height=\"760\" srcset=\"https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/loopback-api-overview.png 1000w, https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/loopback-api-overview-300x228.png 300w, https:\/\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/loopback-api-overview-768x584.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/p>\n<p>The next step would be to <a href=\"https:\/\/strongloop.com\/projects\/#mg\">secure the API using microgateway<\/a> for API Key validation, OAuth 2.0 and rate limiting,<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the aspects I like the most about SAP HANA is the cloud app development environment that allows you to quickly put together a data-entry app using Fiori. Recently, I wanted to build a small JavaScript app for data querying and entry using the awesome ag-grid. The data was in SAP HANA but the&hellip; <a class=\"more-link\" href=\"https:\/\/www.danielpradilla.info\/blog\/how-to-build-an-api-for-sap-hana-using-strongloop-loopback\/\">Continue reading <span class=\"screen-reader-text\">How to build an API for SAP HANA using strongloop\/loopback<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[331],"tags":[],"class_list":["post-2234","post","type-post","status-publish","format-standard","hentry","category-software-development-en-en","entry"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1tlzy-A2","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":2174,"url":"https:\/\/www.danielpradilla.info\/blog\/how-to-connect-pentaho-data-integration-to-sap-hana\/","url_meta":{"origin":2234,"position":0},"title":"How to Connect Pentaho Data Integration to SAP HANA","author":"Daniel Pradilla","date":"22\/06\/2016","format":false,"excerpt":"Recently I had to connect Pentaho Data Integration to SAP HANA and I made some notes along the way: The first step is to get the SAP HANA JDBC driver, a file called ngdbc.jar. The quickest way is to\u00a0download and install the SAP HANA client from the SAP Software Download\u2026","rel":"","context":"In &quot;Software Dev.&quot;","block_context":{"text":"Software Dev.","link":"https:\/\/www.danielpradilla.info\/blog\/category\/software-development-en-en\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2016\/06\/pentaho-saphana.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2016\/06\/pentaho-saphana.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2016\/06\/pentaho-saphana.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2239,"url":"https:\/\/www.danielpradilla.info\/blog\/how-to-connect-to-sap-hana-using-jdbc\/","url_meta":{"origin":2234,"position":1},"title":"How to connect to SAP HANA using JDBC","author":"Daniel Pradilla","date":"27\/08\/2018","format":false,"excerpt":"Recently I had to connect a Java application to SAP HANA and I made some notes along the way: The first step is to get the SAP HANA JDBC driver, a file called ngdbc.jar. The quickest way is to download\u00a0the SAP Hana Cloud Platform SDK from here: https:\/\/tools.hana.ondemand.com\/#cloud Choose the\u2026","rel":"","context":"In &quot;Software Dev.&quot;","block_context":{"text":"Software Dev.","link":"https:\/\/www.danielpradilla.info\/blog\/category\/software-development-en-en\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/08\/SAP-HANA-Certified.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2212,"url":"https:\/\/www.danielpradilla.info\/blog\/linear-optimization-with-or-tools-building-a-web-front-end-with-falcon-and-gunicorn\/","url_meta":{"origin":2234,"position":2},"title":"Linear Optimization with or-tools \u00e2\u20ac\u201d building a web front-end with falcon and gunicorn","author":"Daniel Pradilla","date":"14\/11\/2017","format":false,"excerpt":"In a previous post, I put together a script for solving a linear optimisation problem using Google's OR-tools. This python script is callable from the command line and you kinda need to know what you are doing and how to organize the parameters. So, in order to address this difficulty,\u2026","rel":"","context":"In &quot;Software Dev.&quot;","block_context":{"text":"Software Dev.","link":"https:\/\/www.danielpradilla.info\/blog\/category\/software-development-en-en\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2017\/11\/groceryshopping.gif?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2017\/11\/groceryshopping.gif?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2017\/11\/groceryshopping.gif?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2017\/11\/groceryshopping.gif?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":2229,"url":"https:\/\/www.danielpradilla.info\/blog\/linear-optimization-with-or-tools-containerizing-a-gunicorn-web-application\/","url_meta":{"origin":2234,"position":3},"title":"Linear optimization with or-tools: containerizing a gunicorn web application","author":"Daniel Pradilla","date":"15\/05\/2018","format":false,"excerpt":"Previously, we left our app working with our local python+gunicorn+nginx installation. In order to get there we had to do quite a bit of configuration and if we wanted to deploy this in a server or send it to a friend, we would have to go through a very error-prone\u2026","rel":"","context":"In &quot;Software Dev.&quot;","block_context":{"text":"Software Dev.","link":"https:\/\/www.danielpradilla.info\/blog\/category\/software-development-en-en\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/docker.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/docker.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2018\/05\/docker.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1973,"url":"https:\/\/www.danielpradilla.info\/blog\/improve-sap-business-objects\/","url_meta":{"origin":2234,"position":4},"title":"How to improve your Business Objects charts","author":"Daniel Pradilla","date":"13\/08\/2013","format":false,"excerpt":"Business Objects, SAP's BI platform, is notoriously bad for data visualization. Somehow, it empowers the developers to make all the wrong decisions at the same time and create really ugly and unusable \"dashboards\". Lately, I've seen my share of ugly bobip visualizations, like the one above. Which would seem ok\u2026","rel":"","context":"In &quot;Project Mgmt.&quot;","block_context":{"text":"Project Mgmt.","link":"https:\/\/www.danielpradilla.info\/blog\/category\/projectmanagement-en\/"},"img":{"alt_text":"disaster, disguised as a \"dashboard\"","src":"https:\/\/i0.wp.com\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2013\/08\/Slide-5-SAP-BusinessObjects-4.0-Event-Insight2.jpg?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2013\/08\/Slide-5-SAP-BusinessObjects-4.0-Event-Insight2.jpg?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.danielpradilla.info\/blog\/wp-content\/uploads\/2013\/08\/Slide-5-SAP-BusinessObjects-4.0-Event-Insight2.jpg?resize=525%2C300 1.5x"},"classes":[]},{"id":2224,"url":"https:\/\/www.danielpradilla.info\/blog\/pentaho-is-slow-for-servers-with-too-many-home-directories\/","url_meta":{"origin":2234,"position":5},"title":"Pentaho is slow for servers with too many home directories","author":"Daniel Pradilla","date":"28\/04\/2018","format":false,"excerpt":"Over the course of two years, browsing solutions on our Pentaho 5.4 server became progressively slow. It came to a point in which you had to wait 2-3 minutes to see the list of solutions in the Pentaho User Console. The catalina log didn't say much and we didn't have\u2026","rel":"","context":"In &quot;Software Dev.&quot;","block_context":{"text":"Software Dev.","link":"https:\/\/www.danielpradilla.info\/blog\/category\/software-development-en-en\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.danielpradilla.info\/blog\/wp-json\/wp\/v2\/posts\/2234","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.danielpradilla.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.danielpradilla.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.danielpradilla.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.danielpradilla.info\/blog\/wp-json\/wp\/v2\/comments?post=2234"}],"version-history":[{"count":0,"href":"https:\/\/www.danielpradilla.info\/blog\/wp-json\/wp\/v2\/posts\/2234\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.danielpradilla.info\/blog\/wp-json\/wp\/v2\/media?parent=2234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.danielpradilla.info\/blog\/wp-json\/wp\/v2\/categories?post=2234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.danielpradilla.info\/blog\/wp-json\/wp\/v2\/tags?post=2234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}