iModernize - The Profound Logic Software Blog

NodeRun Guided Lab: Employee Data Application - Part 8

Posted by Profound Logic on May 28, 2019 11:55:09 AM


NodeRun trans

NodeRun
is the newest Profound Logic product dedicated to making it easier for Node.js developers to create applications by moving development to a cloud-based environment. NodeRun comes with a full IDE with Visual Designer, editor, debugger, and Node.js already pre-installed. Some of NodeRun's most notable capabilities include design screens, the ability to develop and run application within the program, full debugging capabilities, the ability to install NPM packages, manage your own Node.js server, work with active sessions to see end-user activity, host database and built-in Database Explorer, a command-line terminal for full control of your space, as well as the ability to share and collaborate with other developers.

Getting started with NodeRun is quick and easy. All you need is a modern internet browser (Google Chrome, Mozilla Firefox, etc.) and that's it. Every NodeRun Space is free to build and comes with its own files, database, and server. To get started visit NodeRun.com create an account and begin developing, it's that easy!

This 8 part blog series will give you a set of exercises to help you build a Node.js applications that work with employee data. Last week we discussed how to Consume a Web Service, and this week, we will show you how to use NPM to be able to email your employee list application. 

Exercise 10 - Using NPM to Email Employee List

In this exercise, you will write code to email a list of employees to yourself. In the toolbar under the Your App section, click the Server drop-down and click the  Install NPM Packages button. Next, add the name'gmail-send' to the Install NPM Packages window and press 'Ok.' 

npm add
Alternatively, use the Terminal feature and type: NPM install gmail-send.

What is NPM?

  • www.npmjs.com hosts a repository of reusable Node.js packages
  • There are many packages for almost every imaginable purpose
  • Packages will often use other packages
  • For example, nodemailer is a popular package for sending emails
  • gmail-send is a package that implements nodemailer but simplifies usage specifically for sending emails from a gmail account

Create Node.js Script Named email.js

 In the toolbar press the New drop-down menu and select JavaScript File.

new javascript-2

Once you open a new JavaScript File, write the code that is below: 

email code
After you write out the above code, save this JavaScript File as email.js.

Code Explained

  • require() is a Node.js API that loads files or loads installed npm packages
  • require('gmail-send') loads the gmail-send package
  • require('./credentials.json') loads gmail account credentials from a json file

Test the Email Functionality

 

In your toolbar press the Launch drop-down menu and select Launch App in Browser button. Next, press the Email Employee List (NPM) button. 

NPM test button

Please note:

  • Don't click the option more than once! The menu will remain on screen after the email is sent.
  • Check your inbox to see if you received the employee list.

 


You are all done! Thanks for trying out this lab!

As a next step, try to think of creative ways to enhance the screens or the functionality behind the screens you built.

Please leave any questions or comments you might have for us here.

If you missed out on any of our previous Guided Labs here is a recap of those exercises:

Topics: RPG Development, Application modernization, IBM i applications, Node.js, Profound.js, IBM i, RPG, AS400 modernization, IBM i Modernization, Agile modernization, iSeries, Legacy Modernization, Profound UI, AS 400, AS_400, Profound Logic

Subscribe to Blog Updates

...and get The 2019 State of IBM i Modernization White Paper FREE!

cover page 2019-1

Recent Posts