Domino v10 development will bring us Node.js integration in the form of the “NERD” stack - Node, Express, React and Domino. Using Node and React programming skills developers will be able to access Domino data via a Domino module running under Node. BUT WHAT IS NODE? In this session Tim explains what Node is, how to work with it, and how Domino developers will be be able to take advantage of this new platform.
15. Add a listener
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World!n');
});
• Don’t worry about the strange arrow =>, that is just a different way of saying
function, more on this later
• This acts on the request req and the response res
• Status 200 is 'success OK'
• Tells browser to expect some text
• Adds our text and tells the server to send the response
16. Tell it to start listening
const hostname = '127.0.0.1';
const port = 3000;
server.listen(port, hostname, () =>
{ console.log(`Server running at http://$
{hostname}:${port}/`); });
•This tells the server to listen on port 3000 and prints a
message to the Node console
•This is all we need, only 11 lines of code.
31. What about Domino?
• Install the Domino DB connector
npm install dominodb
• Will be able to use code something like this in your routes:
const { domServer } = require('domino-db');
domServer(serverConfig).then(
async (server) => {
const db = await server.useDatabase(dbConfig);
const docs = await db.bulkReadDocuments(query);
}
• The query can be the new Domino General Query Framework
• NDA, but for more on this, see John Curtis' session Weds 11am
40. Arrow functions =>
•The arrow is similar to the traditional 'function', so
(arg1, arg2) => { ..code.. }
– kind of works like:
function ( arg1, arg2 ) { ..code.. }
•Difference is when you use 'this'
– with 'function', the 'this' is what calls the function
– with '=>', the 'this' is from outside what calls the function
– (More or less, it's worth reading up on)
•Great when passing functions as parameters in Node
modules, where you want 'this' to be the overall node app
42. Async example
function getDataAsync() {
… do a lookup …
console.log("got data");
}
console.log("start");
getDataAsync();
console.log("finish");
• The output is:
start
finish
got data