"Alpha Anywhere's ability to run server side Javascript is just an amazing feature" - KKFIN (Developer using Alpha Anywhere)


"Alpha Anywhere's ability to run server side Javascript is just an amazing feature" - KKFIN (Developer using Alpha Anywhere)

The following message is reproduced verbatim from the Alpha Message board and we have turned it into a blog post because we think it will be of interest to developers using Alpha Anywhere 

  "One thing that has had surprisingly little attention is Alpha Anywhere's ability to run server side javascript. This is just an amazing feature. This feature makes also possible to run javascript directly in web page template. Little Example template
<!doctype html>
<html lang="en">
  <meta charset="UTF-8">
  <title>Little Example</title>
  <%= new Date() %>
 <h1>My Little Example Template</h1>
In bold above is pure javascript function inside <% %> tags that renderes date when page is loaded.( Note that no library is loaded ).

This is possible because Alpha Anywhere has integrated Node.js - https://en.wikipedia.org/wiki/Node.js

What is interesting is that above page is rendered in Nodejs server not in Alpha Anywhere server so if you are running AA server in port 80 you can for example make above page available at port 3000 ( or any other port). This opens endless possibilities from a developers point of view. Here is example to get started. 1. Find in Alphas install directory node_services directory and put this file expressown.js to it.
exports.handler = function(packet,response,sendResponse) {

	var express = require('express');
	var path = require('path');
	var app = express();
	app.set('view engine', 'ejs');
	app.set('views', path.join(__dirname, 'views'));
	// Start the app

	app.get('/', function(req, res) {

	app.listen(3000, function() {
	console.log('Express app started on port 3000');

		response.result = 'Server is running on port 3000'
2. Make new folder in node_services folder and name it as views and put in it the little example template and name it index.ejs 3. Make normally in your Developer dateejs.a5w page and put inside:
dim n as Helper::V8
dim p as p
p._id = api_uuidcreate()
p._command = "expressown"
dim jsoncmd as c
jsoncmd = json_generate(p)
? n.NodeRequest(jsoncmd)
? p._command
4. Publish dateejs.a5w and open it in browser and then open new tab and go to http://localhost:3000 and you see the little example template rendered. Note this is Nodejs server not Alpha server running.

This is just little example. Developers heaven is in javascript and it is available in Alpha Anywhere.

Note: expressown.js is running in server and user will never see the code in client side so you can protect your own code."
Alpha's Supercharged PhoneGap Build Integration: HTML5 Hybrid Apps with Native Features
Develop Better Mobile Apps: Design Them Around Enterprise Workflows

About Author

Richard Rabins
Richard Rabins

Co-founder of Alpha Software, Richard Rabins focuses on strategy, sales, and marketing. Richard also served as CEO of SoftQuad International from 1997 to 2001, when it owned Alpha. In addition to his 30 years with the company, Richard played a key role as co-founder, and served as president and chairman of the Massachusetts Software Council (now the Massachusetts Technology Leadership Council), the largest technology trade organization in Massachusetts. Prior to founding Alpha, Richard was a project leader and consultant with Information Resources, Inc. (IRI), and a management consultant with Management Decision Systems, Inc. Richard holds a master's degree in system dynamics from the Sloan School at MIT, and a bachelor's degree in electrical engineering and master's degree in control engineering from University of the Witwatersrand in Johannesburg, South Africa. He has served on the boards of Silent Systems, Legacy Technology and O3B Networks, and is co-founder of Tubifi www.tubifi.com.


Subscribe To Blog

Subscribe to Email Updates