Skip to content

totemorg/totem

Repository files navigation

TOTEM provides a web service with the following basic features:

  • endpoint routing
  • http/https service
  • denial-of-service protection
  • secure link for encrypted inter-client communications and antibot protection
  • client profiles
  • PKI encryption and authentication
  • fault protected run states
  • indexing, uploading, downloading and cacheing static files
  • crud interface to notebooks, mysql and neo4j databases
  • task queuing and regulation
  • watchdog periodic file polling and services
  • cert generation
  • task sharding
  • file stream and ingest
  • data fetching using various protocols
  • smartcard reader
  • site skinning

TOTEM defines POST-GET-PUT-DELETE endpoint NODEs:

DATASET.TYPE ? QUERY
NOTEBOOK.TYPE ? QUERY
AREA/PATH/FILE.TYPE ? QUERY
HOOK.TYPE ? QUERY

to access DATASETs, NOTEBOOKs, FILEs and HOOKs as described in TOTEM's API and skinning guide.

A TYPE can filter DATASETs:

db | xml | csv | txt | html | json | blog

or render NOTEBOOKs:

view

The following HOOKs:

riddle | task | ping | login | agent

validate sessions, shard tasks, test connections, establish secure link with clients, and interface with in-network task agents.

Manage

npm install @totemorg/totem		# install base service
npm install @totemorg/dbs		# install database schema

npm run start [ ? | $ | ...]	# Unit test
npm run verminor				# Roll minor version
npm run vermajor				# Roll major version
npm run redoc					# Regen documentation

npm run	startdbs				# Start required database servers
npm run setprot					# Configure for protected mode
npm run setdebug				# Configure for debugging mode
npm run setoper					# Configure for operational mode
npm run setprod					# Configure for production mode

Usage

Acquire, optionally configure and start a TOTEM server:

const TOTEM = require("@totemorg/totem").config({
	key: value, 						// set key
	"key.key": value, 					// indexed set
	"key.key.": value					// indexed append
}, sql => {
	console.log( sql ? "look mom - Im running!" : "something evil is lurking" );
});

where configuration keys follow ENUMS deep copy conventions.

Program Reference

Open/Close ## Modules
String
Array
TOTEM

Provides a barebones web service. This module documented in accordance with jsdoc.

Env Dependencies

SERVICE_PASS = passphrase to server pki cert
URL_MASTER = URL to master totem service service
URL_WORKER = URL to worker totem service service
SHARD0 = PROTO://DOMAIN:PORT
SHARD1 = PROTO://DOMAIN:PORT
SHARD2 = PROTO://DOMAIN:PORT
SHARD3 = PROTO://DOMAIN:PORT

String

String~linkify(ref) ⇐ String

Returns a ref-joined list of links

Kind: inner method of String
Extends: String

Param Type
ref String

String~mailify(ref) ⇐ String

Returns a link suitable to ref host email system

Kind: inner method of String
Extends: String

Param Type
ref String

String~parseXML(cb) ⇐ String

Parse XML string into json and callback cb(json)

Kind: inner method of String
Extends: String

Param Type Description
cb function callback( json

Array

Array~gridify(noheader)

Creates an html table from an array.

Kind: inner method of Array

Param Type Description
noheader Boolean switch to enable header processing

Array~groupify(dot)

Groups each "x.y.z. ...." spec in the list.

Kind: inner method of Array

Param Type Description
dot string item seperator

Array~blog(keys, ds, cb)

Blogs each string in the list.

Kind: inner method of Array
See: totem:blogify

Param Type Description
keys List list of keys to blog
ds String Name of dataset being blogged
cb function callback(recs) blogified version of records

Array~joinify(cb)

Joins a list with an optional callback cb(head,list) to join the current list with the current head.

Kind: inner method of Array

Param Type
cb function

Example

[	a: null,
		g1: [ b: null, c: null, g2: [ x: null ] ],
		g3: [ y: null ] ].joinify()

returning a string
	"a,g1(b,c,g2(x)),g3(y)"

TOTEM

Provides a barebones web service. This module documented in accordance with jsdoc.

Env Dependencies

SERVICE_PASS = passphrase to server pki cert
URL_MASTER = URL to master totem service service
URL_WORKER = URL to worker totem service service
SHARD0 = PROTO://DOMAIN:PORT
SHARD1 = PROTO://DOMAIN:PORT
SHARD2 = PROTO://DOMAIN:PORT
SHARD3 = PROTO://DOMAIN:PORT

Requires: module:enums, module:jsdb, module:securelink, module:http, module:https, module:fs, module:constants, module:cluster, module:child_process, module:os, module:stream, module:vm, module:crypto, module:mime, module:xml2js, module:toobusy-js, module:json2csv, module:js2xmlparser, module:cheerio
Author: ACMESDS
Example

// npm test T1
// Create simple service but dont start it.
Log({
	msg: "Im simply a Totem interface so Im not even running as a service", 
	default_fetcher_endpts: TOTEM.byNode,
	default_protect_mode: TOTEM.guard,
	default_cores_used: TOTEM.cores
});

Example

// npm test T2
// Totem service running in fault protection mode, no database, no UI; but I am running
// with 2 workers and the default endpoint routes.

config({
	mysql: null,
	guard: true,
	cores: 2
}, sql => {

	Log( 
`I'm a Totem service running in fault protection mode, no database, no UI; but I am running
with 2 workers and the default endpoint routes` );

});

Example

// npm test T3
// A Totem service with no workers.

config({
}, sql => {
	Log( 
`I'm a Totem service with no workers. I do, however, have a mysql database from which I've derived 
my startup options (see the openv.apps table for the Nick="Totem1").  
No endpoints to speak off (execept for the standard wget, riddle, etc) but you can hit "/files/" to index 
these files. `
	);
});

Example

// npm test T4
// Only 1 worker, unprotected, a mysql database, and two endpoints.

config({
	byNode: {
		dothis: function dothis(req,res) {  //< named handlers are shown in trace in console
			res( "123" );

			Log("", {
				do_query: req.query
			});
		},

		dothat: function dothat(req,res) {

			if (req.query.x)
				res( [{x:req.query.x+1,y:req.query.x+2}] );
			else
				res( new Error("We have a problem huston") );

			Log("", {
				msg: `Like dothis, but needs an ?x=value query`, 
				or_query: req.query,
				or_user: req.client
			});
		}
	}
}, sql => {
	Log("", {
		msg:
`As always, if the openv.apps Encrypt is set for the Nick="Totem" app, this service is now **encrypted** [*]
and has https (vs http) endpoints, here /dothis and /dothat endpoints.  Ive only requested only 1 worker (
aka core), Im running unprotected, and have a mysql database.  
[*] If my NICK.pfx does not already exists, Totem will create its password protected NICK.pfx cert from the
associated public NICK.crt and private NICK.key certs it creates.`,
		my_endpoints: T.byNode
	});
});

Example

// npm test T5
// no cores but a mysql database and an anti-bot shield

config({
	"login.challenge.extend": 20
}, sql => {
	Log("", {
		msg:
`I am Totem client, with no cores but I do have mysql database and I have an anti-bot shield!!  Anti-bot
shields require a Encrypted service, and a UI (like that provided by DEBE) to be of any use.`, 
		mysql_derived_parms: T.site
	});
});

Example

// npm test T6
// Testing tasker with database, 3 cores and an additional /test endpoint.

config({
	guard: false,	// ex override default 
	cores: 3,		// ex override default

	"byNode.": {  // define endpoints
		test: function (req,res) {
			res(" here we go");  // endpoint must always repond to its client 
			if (isMaster)  // setup tasking examples on on master
				switch (req.query.opt || 1) {  // test example runTask
					case 1: 
						T.runTask({  // setup tasking for loops over these keys
							keys: "i,j",
							i: [1,2,3],
							j: [4,5]
						}, 
							// define the task which returns a message msg
							($) => "hello i,j=" + [i,j] + " from worker " + $.worker + " on " + $.node, 

							// define the message msg handler
							(msg) => console.log(msg)
						);
						break;

					case 2:
						T.runTask({
							qos: 1,
							keys: "i,j",
							i: [1,2,3],
							j: [4,5]
						}, 
							($) => "hello i,j=" + [i,j] + " from worker " + $.worker + " on " + $.node, 
							(msg) => console.log(msg)
						);
						break;

					case 3:
						break;
				}

		}
	}

}, sql => {
	Log( "Testing runTask with database and 3 cores at /test endpoint" );
});

Example

// npm test T7
// Conduct db maintenance

config({
}, sql => {				
	Log( "db maintenance" );

	if (isMaster)
		switch (process.argv[3]) {
			case 1: 
				sql.query( "select voxels.id as voxelID, chips.id as chipID from openv.voxels left join openv.chips on voxels.Ring = chips.Ring", function (err,recs) {
					recs.forEach( rec => {
						sql.query("update openv.voxels set chipID=? where ID=?", [rec.chipID, rec.voxelID], err => {
							Log(err);
						});
					});
				});
				break;

			case 2:
				sql.query("select ID, Ring from openv.voxels", function (err, recs) {
					recs.forEach( rec => {
						sql.query(
							"update openv.voxels set Point=geomFromText(?) where ?", 
							[ `POINT(${rec.Ring[0][0].x} ${rec.Ring[0][0].y})` , {ID: rec.ID} ], 
							err => {
								Log(err);
						});
					});
				});
				break;

			case 3:
				sql.query( "select voxels.id as voxelID, cache.id as chipID from openv.voxels left join openv.cache on voxels.Ring = cache.geo1", function (err,recs) {
					Log(err);
					recs.forEach( rec => {
						sql.query("update openv.voxels set chipID=? where ID=?", [rec.chipID, rec.voxelID], err => {
							Log(err);
						});
					});
				});
				break;

			case 4:
				sql.query("select ID, geo1 from openv.cache where bank='chip'", function (err, recs) {
					recs.forEach( rec => {
						if (rec.geo1)
							sql.query(
								"update openv.cache set x1=?, x2=? where ?", 
								[ rec.geo1[0][0].x, rec.geo1[0][0].y, {ID: rec.ID} ], 
								err => {
									Log(err);
							});
					});
				});
				break;

			case 5: 
				var parms = {
ring: "[degs] closed ring [lon, lon], ... ]  specifying an area of interest on the earth's surface",
"chip length": "[m] length of chip across an edge",
"chip samples": "[pixels] number of pixels across edge of chip"
				};
				//get all tables and revise field comments with info data here -  archive parms - /parms in flex will
				//use getfileds to get comments and return into

			case 6:
				var 
					RAN = require("../randpr"),
					ran = new RAN({
						models: ["sinc"],
						Mmax: 150,  // max coherence intervals
						Mstep: 5 	// step intervals
					});

				ran.config( function (pc) {
					var 
						vals = pc.values,
						vecs = pc.vectors,
						N = vals.length, 
						ref = vals[N-1];

					vals.forEach( (val, idx) => {
						var
							save = {
								correlation_model: pc.model,
								coherence_intervals: pc.intervals,
								eigen_value: val,
								eigen_index: idx,
								ref_value: ref,
								max_intervals: ran.Mmax,
								eigen_vector: JSON.stringify( vecs[idx] )
							};

						sql.query("INSERT INTO openv.pcs SET ? ON DUPLICATE KEY UPDATE ?", [save,save] );	
					});
				});
				break;	
		}
});		

Example

// npm test T8
// Conduct neo4j database maintenance

const $ = require("../man/man.js");
config();
neoThread( neo => {
	neo.cypher( "MATCH (n:gtd) RETURN n", {}, (err,nodes) => {
		Log("nodes",err,nodes.length,nodes[0]);
		var map = {};
		nodes.forEach( (node,idx) => map[node.n.name] = idx );
		//Log(">map",map);

		neo.cypher( "MATCH (a:gtd)-[r]->(b:gtd) RETURN r", {}, (err,edges) => {
			Log("edges",err,edges.length,edges[0]);
			var 
				N = nodes.length,	
				cap = $([N,N], (u,v,C) => C[u][v] = 0 ),
				lambda = $([N,N], (u,v,L) => L[u][v] = 0),
				lamlist = $(N, (n,L) => L[n] = [] );

			edges.forEach( edge => cap[map[edge.r.srcId]][map[edge.r.tarId]] = 1 );

			//Log(">cap",cap);

			for (var s=0; s<N; s++)
				for (var t=s+1; t<N; t++) {
					var 
						{cutset} = $.MaxFlowMinCut(cap,s,t),
						cut = lambda[s][t] = lambda[t][s] = cutset.length;

					lamlist[cut].push([s,t]);
				}

			lamlist.forEach( (list,r) => {
				if ( r && list.length ) Log(r,list);
			});

		});
	});
});	

TOTEM.busy

Service too-busy options to deny DoS attacks.

Kind: static property of TOTEM
Cfg: Object

TOTEM.CORS

Enable to support cross-origin-scripting

Kind: static property of TOTEM
Cfg: Boolean

TOTEM.defaultType

Default NODE type during a route

Kind: static property of TOTEM
Cfg: String

TOTEM.login

Login configuration settings for secureLink. Null to disable the secureLink.

Kind: static property of TOTEM
Cfg: Object

login.sio

Socketio i/f set on SECLINK config

Kind: static property of login

login.host

Name of SECLINK host for determining trusted clients etc

Kind: static property of login

login.challenge

Specifiies client challenge options for the anti-bot security

Kind: static property of login

challenge.extend

Number of antibot riddles to extend

Kind: static property of challenge
Cfg: Number [extend=0]

login.inspect()

Used to inspect unencrypted messages

Kind: static method of login

TOTEM.nodeRouter

Hash of node routers to provide access-control on nodes. The router accepts a req request and return a fulling qualified mysql path "db.name" if the access is granted; or returned a "black.name" if access is denied.

Kind: static property of TOTEM

TOTEM.errors

Error messages

Kind: static property of TOTEM
Cfg: Object

TOTEM.queues

Job queues provided by JSDB.

Kind: static property of TOTEM

TOTEM.tasking

Methods available when Task Sharding

Kind: static property of TOTEM
Cfg: Object

TOTEM.dogs

Watchdogs {name: dog(sql, lims), ... } run at intervals dog.cycle seconds usings its dog.trace, dog.parms, sql connector and threshold parameters.

Kind: static property of TOTEM
Cfg: Object

TOTEM.stop

Stop the server.

Kind: static property of TOTEM
Cfg: Function

TOTEM.sqlThread

Thread a new sql connection to a callback.

Kind: static property of TOTEM
Cfg: Function

Param Type Description
cb function callback(sql connector)

TOTEM.neoThread

Thread a new neo4j connection to a callback.

Kind: static property of TOTEM
Cfg: Function

Param Type Description
cb function callback(sql connector)

TOTEM.crudIF

REST-to-CRUD translations

Kind: static property of TOTEM
Cfg: Object

TOTEM.cores

Number of worker cores (0 for master-only). If cores>0, masterport should != workPort, master becomes HTTP server, and workers become HTTP/HTTPS depending on encrypt option. In the coreless configuration, master become HTTP/HTTPS depending on encrypt option, and there are no workers. In this way, a client can access stateless workers on the workerport, and stateful workers via the masterport.

Kind: static property of TOTEM
Cfg: Number [cores=0]

TOTEM.onFile

Folder watching callbacks cb(path)

Kind: static property of TOTEM
Cfg: Object

TOTEM.modTimes

File mod-times tracked as OS will trigger multiple events when file changed

Kind: static property of TOTEM
Cfg: Object

TOTEM.behindProxy

Enable if https server being proxied

Kind: static property of TOTEM
Cfg: Boolean [behindProxy=false]

TOTEM.name

Service name used to 1) derive site parms from mysql openv.apps by Nick=name 2) set mysql name.table for guest clients, 3) identify server cert name.pfx file.

If the Nick=name is not located in openv.apps, the supplied config() options are not overridden.

Kind: static property of TOTEM

TOTEM.certPass

Enabled when master/workers on encrypted service

Kind: static property of TOTEM
Cfg: Boolean

TOTEM.site

Site context extended by the mysql derived query when service starts

Kind: static property of TOTEM
Cfg: Object

TOTEM.filters

Endpoint filters cb(data data as string || error)

Kind: static property of TOTEM
Cfg: Object

filters.txt(recs, req, res)

Kind: static method of filters

Param Type Description
recs Array Records to filter
req Object Totem session request
res function Totem session response

filters.db(recs, req, res)

Kind: static method of filters

Param Type Description
recs Array Records to filter
req Object Totem session request
res function Totem session response

filters.html(recs, req, res)

Kind: static method of filters

Param Type Description
recs Array Records to filter
req Object Totem session request
res function Totem session response

filters.blog(recs, req, res)

Kind: static method of filters

Param Type Description
recs Array Records to filter
req Object Totem session request
res function Totem session response

filters.csv(recs, req, res)

Kind: static method of filters

Param Type Description
recs Array Records to filter
req Object Totem session request
res function Totem session response

filters.json(recs, req, res)

Kind: static method of filters

Param Type Description
recs Array Records to filter
req Object Totem session request
res function Totem session response

filters.xml(recs, req, res)

Kind: static method of filters

Param Type Description
recs Array Records to filter
req Object Totem session request
res function Totem session response

TOTEM.byNode

By-node endpoint routers {node: method(req,res), ... } for data fetchers, system and user management

Kind: static property of TOTEM
Cfg: Object

byNode.agent(req, res)

Endpoint to interface with in-network agents given request query

port		Port number to register an agent
keys		Query keys to register an agent
tasks		List of tasks to be run

Kind: static method of byNode

Param Type Description
req Object Totem session request
res function Totem session response

byNode.ping(req, res)

Endpoint to test connectivity.

Kind: static method of byNode

Param Type Description
req Object Totem request
res function Totem response

byNode.task(req, res)

Endpoint to shard a task to the compute nodes.

Kind: static method of byNode

Param Type Description
req Object Totem request
res function Totem response

byNode.riddle(req, res)

Endpoint to validate clients response to an antibot challenge.

Kind: static method of byNode

Param Type Description
req Object Totem session request
res function Totem response callback

byNode.login(req, res)

Endpoint to validate clients response to an antibot challenge.

Kind: static method of byNode

Param Type Description
req Object Totem session request
res function Totem response callback

TOTEM.byAction

By-action endpoint routers for accessing engines

Kind: static property of TOTEM
Cfg: Object

byAction.select(req, res)

CRUD endpoint to respond to a select||GET request

Kind: static method of byAction
Cfg: Function

Param Type Description
req Object Totem session request
res function Totem session response

byAction.update(req, res)

CRUD endpoint to respond to a update||POST request

Kind: static method of byAction
Cfg: Function

Param Type Description
req Object Totem session request
res function Totem session response

byAction.delete(req, res)

CRUD endpoint to respond to a delete||DELETE request

Kind: static method of byAction
Cfg: Function

Param Type Description
req Object Totem session request
res function Totem session response

byAction.insert(req, res)

CRUD endpoint to respond to a insert||PUT request

Kind: static method of byAction
Cfg: Function

Param Type Description
req Object Totem session request
res function Totem session response

byAction.execute(req, res)

CRUD endpoint to respond to a Totem request

Kind: static method of byAction
Cfg: Function

Param Type Description
req Object Totem session request
res function Totem session response

TOTEM.byType

By-type endpoint routers {type: method(req,res), ... } for accessing dataset readers

Kind: static property of TOTEM
Cfg: Object

TOTEM.byArea

By-area endpoint routers {area: method(req,res), ... } for sending/cacheing/navigating files

Kind: static property of TOTEM
Cfg: Object

byArea.default(req, res)

Default area navigator.

Kind: static method of byArea

Param Type Description
req Object Totem session request
res function Totem session response

byArea.root(req, res)

Navigator for root area.

Kind: static method of byArea

Param Type Description
req Object Totem session request
res function Totem session response

TOTEM.trustStore

Trust store extened with certs in the certs.truststore folder when the service starts in encrypted mode

Kind: static property of TOTEM
Cfg: Object

TOTEM.server

CRUD endpoint to respond to Totem request

Kind: static property of TOTEM
Cfg: Object

TOTEM.guard

Enable/disable service fault protection guards

Kind: static property of TOTEM
Cfg: Boolean

TOTEM.guards

Service guard modes

Kind: static property of TOTEM
Cfg: Object

TOTEM.admitRules

Client admission rules

Kind: static property of TOTEM
Cfg: Object

TOTEM.proxies

List of rotating proxies when doing masked Fetches.

Kind: static property of TOTEM

TOTEM.paths

Default paths to service files

Kind: static property of TOTEM
Cfg: Object

TOTEM.sqls

Kind: static property of TOTEM

TOTEM.uploadFile

File uploader

Kind: static property of TOTEM
Cfg: Function

TOTEM.busyTime

Server toobusy check period in seconds

Kind: static property of TOTEM
Cfg: Number

TOTEM.certs

Kind: static property of TOTEM

TOTEM.cache

File cache

Kind: static property of TOTEM
Cfg: Object

TOTEM.attachAgent(server, port, agents, init)

Attach a (req,res)-agent to thea server listening on the given port. Callsback the supplied agent (when using a node-independent agent) or a agent from the supplied agents hash (assigned by the url-derived path, table, type, area). The req request is built during nested threads.

The outer-most socThread adds socket data to the req request:

cookie: "...."		// client cookie string
agent: "..."		// client browser info
ipAddress: "..."	// client ip address
referer: "http://site"		// url during a cross-site request
method: "GET|PUT|..." 		// http request method
now: date			// date stamp when requested started
post: "..."			// raw body text
url	: "/query"		// requested url path
reqSocket: socket	// socket to retrieve client cert, post etc
resSocket: socket	// method to create socket to accept response
cert: {...} 		// full client cert

The dsThread adds dataset information:

sql: {...}			// sql connector
ds:	"db.name"		// fully qualified sql table
action: "select|update| ..."	// corresponding crude name

The nodeThread adds client data:

encrypted: bool		// true if request on encrypted server
site: {...}			// site info
mimi: "type"		// mime type of response

The resThread adds node information and url parameters:

path: "/[area/...]name.type"	// full node path
area: "name"		// file area being requested
table: "name"		// name of dataset/table being requested
type: "type" 		// type descriptor 

query: {...} 		// raw keys from url
where: {...} 		// sql-ized query keys from url
body: {...}			// body keys from request 
flags: {...} 		// flag keys from url
index: {...}		// sql-ized index keys from url

And the inner-most agentThread adds client information:

client: "..."		// name of client from cert or "guest"
profile: {...},		// client profile after login

Kind: static method of TOTEM

Param Type Description
server Object Server being started
port Numeric Port number to listen for agent requests
agents function | Object the (req,res)-agent or a hash of (req,res)-agents
init function Optional callback after server started

TOTEM.dsThread(req, cb)

Start a dataset ds sql thread and append a sql connector and action to the req request with callback cb(req).

Kind: static method of TOTEM

Param Type Description
req Object Totem endpoint request
cb function callback(revised req)

TOTEM.nodeThread(req, res)

Route NODE = /DATASET.TYPE requests using the configured byArea, byType, byNode, byActionTable then byAction routers.

The provided response method accepts a string, an objects, an array, an error, or a file-cache function and terminates the session's sql connection. The client is validated and their session logged.

Kind: static method of TOTEM
Cfg: Function

Param Type Description
req Object session request
res Object session response

TOTEM.startDogs()

Start watchdogs

Kind: static method of TOTEM

TOTEM.config(opts, cb)

Configure and start the service with options and optional callback when started. Configure database, define site context, then protect, connect, start and initialize this server.

Kind: static method of TOTEM
Cfg: Function

Param Type Description
opts Object configuration options following the Copy() conventions.
cb function callback(err) after service configured

config~configService(agent)

Configure (create, start then initialize) a service that will handle its request-response sessions.

Kind: inner method of config

Param Type Description
agent function callback(req,res) to handle session request-response

configService~createService()

Create and start the HTTP/HTTPS server. If starting a HTTPS server, the truststore is scanned for PKI certs.

Kind: inner method of configService

TOTEM.initialize()

Initialize the dervice.

Kind: static method of TOTEM

TOTEM.runTask(opts, task, cb)

Shard one or more tasks to workers residing in a compute node cloud.

Kind: static method of TOTEM
Cfg: Function

Param Type Description
opts Object tasking options (see example)
task function runTask of the form ($) => {return msg} where $ contains process info
cb function callback of the form (msg) => {...} to process msg returned by task

Example

runTask({  		// example
	keys: "i,j,k",  	// e.g. array indecies
	i: [0,1,2,3],  		// domain of index i
	j: [4,8],				// domain of index j
	k: [0],					// domain of index k
	qos: 0,				// regulation time in ms if not zero
	local: false, 		// enable to run task local, i.e. w/o workers and nodes
	workers: 4, 		// limit number of workers (aka cores) per node
	nodes: 3 			// limit number of nodes (ala locales) in the cluster
}, 
	// here, a simple task that returns a message 
	$ => "my result is " + (i + j*k) + " from " + $.worker + " on "  + $.node,

	// here, a simple callback that displays the task results
	msg => console.log(msg) 
);

TOTEM.watchFile(path, callback)

Establish smart file watcher when file at area/name has changed.

Kind: static method of TOTEM
Cfg: Function

Param Type Description
path String to file being watched
callback function cb(sql, name, path) when file at path has changed

TOTEM.createCert(owner, password, cb)

Create a cert for the desired owner with the desired passphrase then callback cb() when complete.

Kind: static method of TOTEM

Param Type Description
owner String userID to own this cert
password String for this cert
cb function callback when completed

TOTEM.isEncrypted()

Kind: static method of TOTEM

TOTEM.getBrick(client, name, cb)

Get (or create if needed) a file with callback cb(fileID, sql) if no errors

Kind: static method of TOTEM
Cfg: Function

Param Type Description
client String owner of file
name String of file to get/make
cb function callback(file, sql) if no errors

TOTEM.setContext()

Sets the site context parameters.

Kind: static method of TOTEM
Cfg: Function

TOTEM~stopService()

Stop the server.

Kind: inner method of TOTEM

TOTEM~uploadFile(client, source, sinkPath, tags, cb)

Uploads a source stream srcStream to a target file sinkPath owned by the specified client; optional tags are tagged to the upload and the callback cb is made if the upload was successful.

Kind: inner method of TOTEM

Param Type Description
client String file owner
source Stream stream
sinkPath String path to target file
tags Object hash of tags to add to file
cb function callback(file) if upload successful

Contacting, Contributing, Following

Feel free to

License

MIT


© 2012 ACMESDS