Oracle Magazine, May/June 2018
Database Developer OPEN SOURCE folks those modules will be too low level I like to use Express for the web server because its very popular flexible and easy to use There are many other web server options including restify kracken and hapi You might consider some of these options as you experiment more with APIs over time Router Routing logic is used to define the URL endpoints and HTTP methods the API will support At runtime this layer will map incoming requests to the appropriate controller logic The implementation of the routing logic is almost always tied to the choice of web server because most include a means to define routes Ill use the Router class that comes with Express in this series Controllers The controller layer includes one JavaScript function for each URL path HTTP method combination The function will inspect and pull data from the incoming request URL body and HTTP headers as needed interact with appropriate database APIs to fetch or persist data and then generate the HTTP response Database APIs The database APIs will handle the interactions with the database This layer will be isolated from the HTTP request and response Some developers will prefer to use an object relational mapper ORM such as Sequelize to abstract away the database as much as possible For those folks this layer is often called the model layer because ORMs work by defining models in the middle tier Im going to stay lower level and work directly with the Oracle Database driver for Node js node oracledb STARTING UP AND SAYING HELLO The code in this project will be organized with a generic directory structure that can be adjusted and built out over time as needed ORACLE MAGAZINE MAY JUNE 2018 90
You must have JavaScript enabled to view digital editions.