npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fugazi/connector

v1.0.18

Published

basic functionality needed for creating a new fugazi connector using nodejs

Downloads

205

Readme

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.