Building our API using Node.js
In this section, we'll cover connecting our web service to our Oracle database, handling user authentication and session management using Passport, and defining handlers for state transitions.
You'll definitely want to take a look at the /tasker-srv
directory in the code package for this book, which contains the full web server for Tasker. In the following sections, we've only highlighted some snippets of the code.
Connecting to the backend database
Node.js's community has provided a large number of database drivers, so chances are good that whatever your backend, Node.js has a driver available for it. In our example app, we're using an Oracle database as the backend, which means we'll be using the oracle
driver (https://www.npmjs.org/package/oracle).
Connecting to the database is actually pretty easy, the following code shows how:
var oracle = require("oracle"); oracle.connect ( { hostname: "localhost", port: 1521...