Oracle Magazine, July/August 2018
Database Developer OPEN SOURCE Typically you wouldnt use the database module in the web server module but youll add it now just to ensure that its working correctly Open the services webserver js file and add the following line under the existing constant declarations at ORACLE MAGAZINE JULY AUGUST 2018 92 the top line that requires config web server js here const database require database js Next use the following code to replace the entire app get handler that responds with Hello World all three lines line that adds morgan to app here app get async req res const result await database simpleExecute select user systimestamp from dual const user result rows 0 USER const date result rows 0 SYSTIMESTAMP res end DB user user nDate date The new handler is using the database modules simpleExecute function to fetch the current user and systimestamp values from the database The values are then used in a template literal to respond to the client with a dynamic message Start the application again and navigate Firefox to localhost 3000 You should see something like Figure 1 If you see a message like the one in Figure 1 your database module is in good shape
You must have JavaScript enabled to view digital editions.