@fugazi/connector
basic functionality needed for creating a new fugazi connector using nodejs
Last updated 3 years ago by fugazi-admin .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @fugazi/connector 
SYNC missed versions from official npm registry.

fugazi connector.node

A node package for common functionality that is needed for fugazi connectors.
That includes:

  • An http server
  • The ability to add modules, either as files or as raw js objects
  • The ability to add (remote) commands as js objects and functions
  • Automatically adds remote config
  • Supports CORS or serves a proxy frame instead
  • Supports session state
  • A ready to use logger

Installing

The package can be found in npm @fugazi/connector.
Then simply:

npm install --save @fugazi/connector

Building & Running

The package comes with a (very) simple example to illustrate what the connector does.
The example includes two commands which expects a value (any) and return this value, one version is a local command and the other is a remote.

To run the example, first build it:

npm run compile

And then start it:

npm run start
// or
node ./scripts/bin/index.js

You should now see that the connector is up and running and it should print the url for the descriptor, something like:

info: ===== ROUTES START =====
info: # Files:
info:     /examples.local.js
info: # Commands:
info:     GET : /samples.echo/remote/echo
info: # Root modules:
info:     /samples.echo.json
info: ====== ROUTES END ======
info: server started. listening on localhost:3333
info: connector started

Now open the fugazi client (http://fugazi.io) or a locally running instance and load the module:
load module from "http://localhost:3333/samples.echo.json"

After the module was loaded try it:
echo remote hey Or echo local "how are you?"

Using as a package

The connector is created using builders in such a way that building can be chained.
Example of usage (how the echo example is created):

import * as connector from "@fugazi/connector";

const CONNECTOR = new connector.ConnectorBuilder()
	.server()
		.cors(true)
		.parent()
	.module("samples.echo")
		.descriptor({
			title: "Echo example",
			description: "Example of a (echo) remote command using the node connector"
		})
		.module("remote")
			.descriptor({
				title: "Remote echo module",
			})
			.command("echo", {
				title: "Echo command",
				returns: "string",
				syntax: "remote echo (str string)"
			})
			.handler((request) => {
				return { data: request.data("str") };
			})
	.build();

CONNECTOR.start().then(() => {
	CONNECTOR.logger.info("connector started");
});

There's no documentation for the different builders and their methods yet, so until this issue is unresolved please check the contact section below.

Using when cloning

  1. Clone this repo (let's say that it was cloned to /CONNECTOR/PATH)
  2. Install dependencies: /CONNECTOR/PATH > npm install
  3. Compile the scripts:
    /CONNECTOR/PATH > ./node_modules/typescript/bin/tsc -p ./scripts

The rest is the same as the sections above.

Contact

Feel free to create issues if you're running into trouble, and welcome to ask any question in our gitter.

Current Tags

  • 1.0.18                                ...           latest (3 years ago)

15 Versions

  • 1.0.18                                ...           3 years ago
  • 1.0.17                                ...           3 years ago
  • 1.0.16                                ...           3 years ago
  • 1.0.15                                ...           3 years ago
  • 1.0.14                                ...           3 years ago
  • 1.0.13                                ...           3 years ago
  • 1.0.12                                ...           3 years ago
  • 1.0.11                                ...           3 years ago
  • 1.0.9                                ...           3 years ago
  • 1.0.8                                ...           3 years ago
  • 1.0.7                                ...           3 years ago
  • 1.0.6                                ...           3 years ago
  • 1.0.5                                ...           3 years ago
  • 1.0.4                                ...           3 years ago
  • 1.0.3                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (21)
Dev Dependencies (1)

Copyright 2014 - 2016 © taobao.org |