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/proxify

v1.0.1

Published

a fugazi proxy to avoid cross origin issues

Downloads

1

Readme

fugazi proxify

A node package for serving remote APIs as fugazi modules.
It does so by:

  • Serving the module descriptor
  • Proxying all of the requests to the original server and adding CORS headers for the responses

Motivation

The fugazi terminal is restricted by the browser security, and more precisely the Same-origin policy, and so every request made must be served from the same host as the one that fugazi was loaded from.
That can be bypassed using CORS, or by hosting the fugazi proxy-frame, but in some cases changing the configuration of the server which exposes the API isn't easy, or against policies.

By running proxify on the local machine, all the API is "proxyed" with CORS headers and can be loaded into the fugazi terminal.

Installation

npm install @fugazi/proxify

Running

npm start [OPTIONS] descriptor
// OR
node scripts/bin/index.js [OPTIONS] descriptor

descriptor

Either a url or a path to a file to a root module descriptor.

Options

  • --listen-host: The host to which proxify will bind to, default is localhost
  • --listen-port: The port to which proxify will bind to, default is 33334

Contact

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

Example

Let's take an example of a (very) simple http based API for a music database with the following endpoints:

  • GET /labels - returns a list of all record labels

  • GET /artists - returns a list of all artists

  • GET /genres - returns a list of all genres

  • GET /label/{ id } - returns the record label for the given id

  • GET /artist/{ id } - returns the artist for the given id

  • GET /genre/{ id } - returns the genre for the given id

Let's also say that the API is served from http://db.music.com/api.

To use this api from the fugazi client all we need to do is: We create a descriptor file:

{
	"name": "music.db",
	"title": "The music database API",
	"remote": {
		"origin": "http://db.music.com",
		"base": "/api"
	},
	"commands": {
		"allLabels": {
			"returns": "list",
			"syntax": [
				"get all labels",
				"labels"
			],
			"handler": {
				"endpoint": "/labels"
			}
		},
		"allArtists": {
			"returns": "list",
			"syntax": [
				"get all artists",
				"artists"
			],
			"handler": {
				"endpoint": "/artists"
			}
		},
		"allGenres": {
			"returns": "list",
			"syntax": [
				"get all genres",
				"genres"
			],
			"handler": {
				"endpoint": "/genres"
			}
		},
		"getLabel": {
			"returns": "map",
			"syntax": "label (id string)",
			"handler": {
				"endpoint": "/label/{ id }"
			}
		},
		"getArtist": {
			"returns": "map",
			"syntax": "artist (id string)",
			"handler": {
				"endpoint": "/artist/{ id }"
			}
		},
		"getGenre": {
			"returns": "map",
			"syntax": "genre (id string)",
			"handler": {
				"endpoint": "/genre/{ id }"
			}
		}
	}
}

And save it in the directory where we installed the proxify package, let's say ~/fugazi/proxify/music.db.json.
Now we run it:

~/fugazi/proxify> npm start music.db.json

The output should be something like:

server started, listening to localhost:33334
load module descriptor from: http://localhost:33334/music.db.json

Now, inside the fugazi terminal we simply load the module:

load module from "http://localhost:33334/music.db.json"

And then we can just execute the commands:

get all artists
genre 1243tg
etc