Code Monkey home page Code Monkey logo

ibmi-api's Introduction

Node.js IBM i simple API

This application demonstrates a simple, reusable Node.js web application based on the Express framework. It's a template you can use during hands-on, demonstrating how to create REST web service on IBM i with Node.js and SQL.

2 APIs should be exposed, created with simple DB2 for i SQL requests.

Complete the app

You have first to complete the code.
2 web services are defined.

  • The first to retrieve elapsed cpu used
  • The second to retrieve system asp used

Example of code (retrieve % ASP used):

	var result = {};
	var sql = "SELECT system_asp_used FROM QSYS2.SYSTEM_STATUS_INFO"; 
	try {
		console.log("SQL: " + sql);
		db.exec(sql, function(rs) {       
			console.log (JSON.stringify(rs));
			if(rs.length != 0) {
				res.json(rs[0]);
			} else { 
				res.json(204); 	// No content
			}
		});
	} catch(e) {  				// Exception handler
		console.log("Error: " + e);
		res.json(500);
	}

Run the app locally

  1. Install Node.js on IBM i
  • cd into this project's root directory
  • Run npm install to install the app's dependencies
  • Run npm start to start the app
  • Access the running app in a browser at http://IBM-i-hostname:xxxx

ibmi-api's People

Contributors

clalevee avatar skaegi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.