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

proxify-url

v1.0.1

Published

An YQL wrapper used to generate a proxy URL to a given resource.

Downloads

22

Readme

Logo

proxify-url

Build Status Code Climate

An YQL wrapper used to generate a proxy URL to a given resource.

Current version: 1.0.1

Lead Maintainer: Halim Qarroum

Install

Using NPM
npm install --save proxify-url
Using Bower
bower install --save proxify-url

Description

This small component aims to make it possible to issue AJAX requests to third-party resources when it is not possible in normal cases, typically because of CORS or because the remote service does not support JSONP for instance.

The library will generate an URL pointing to the initial resource, but instead of having the browser directly request the remote server for the resource, it will request the Yahoo Query Language API to act as a middle man since it supports CORS and JSONP.

Usage

Proxify an url

Simply require the proxify-url module according to the environment you are in (Node.js, AMD and the browser are supported), and call the returned function with the given URL. An example in the browser would be as follow :

var url = proxify('https://api.github.com/users/octocat');

Note that the returned proxy URL will be secured and that by default the output will be a JSON document.

Options

To customize the proxy URL parameters and how the document is returned by the YQL API, you can pass the following options to the proxify function :

Option key | Description ------------- | ------------- outputformat| The format in which the document must be returned. The default value is json. inputFormat | Indicates in what format the YQL API should be parsing the document. The default value is json. jsonCompat | YQL transforms all JSON data sources into XML before returning results. During the tranformation from XML to JSON, the original JSON may be altered or become "lossy". In other words, the original JSON may not be the same as the returned JSON. By default, this library disables lossy JSON, but you can pass the boolean false to get a lossy JSON. callback | Indicates to the YQL API that it should return the result of the query as a parameter of a function, in a JSONP manner. The value of the callback parameter specifies the name of the function.

Example

The below example will ask the YQL API to parse the document as JSON and to output it as an XML document, and to pass it to a function called foo.

var url = proxify('http://jsonplaceholder.typicode.com/posts', {
  inputFormat: 'json',
  outputFormat: 'xml',
  callback: 'foo'
});

No conflict

Since this module is distributed in the form of an UMD (Univeral Module Definition), it might be easy to use it using module loaders such as RequireJS or require in Node while still keeping the module completely encapsulated.

However, in the context of a browser, the proxify object name is exported in the global namespace. To prevent it from conflicting with another component exporting an object with the same name, you can use the .noConflict function as follow.

var proxy = proxify.noConflict();