GithubHelp home page GithubHelp logo

nkishorchandra / imgix-core-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from imgix/js-core

0.0 1.0 0.0 97 KB

Common boilerplate for imgix server-side JavaScript-based functionality.

License: BSD 2-Clause "Simplified" License

JavaScript 100.00%

imgix-core-js's Introduction

imgix-core-js

Build Status

imgix-core-js is an npm and Bower package that provides the common boilerplate for imgix server and client-side JavaScript-based functionality.

imgix-core-js adheres to the imgix-blueprint for definitions of its functionality.

Installing

imgix-core-js can be installed as either via npm or via bower:

$ npm install --save imgix-core-js

or

$ bower install --save imgix-core-js

Usage

Depending on your module system, using imgix-core-js is done a few different ways. The most common entry point will be the Client class. Whenever you provide data to imgix-core-js, make sure it is not already URL-encoded, as the library handles proper encoding internally.

CommonJS

var ImgixClient = require('imgix-core-js');

var client = new ImgixClient({
  host: "my-social-network.imgix.net",
  secureURLToken: "<SECURE TOKEN>"
});
var url = client.buildURL("/path/to/image.png", {
  w: 400,
  h: 300
});
console.log(url); // => "https://my-social-network.imgix.net/users/1.png?w=400&h=300&s=…"

ES6 Modules

import ImgixClient from 'imgix-core-js'

let client = new ImgixClient({
  host: 'my-social-network.imgix.net',
  secureURLToken: '<SECURE TOKEN>'
});

let url = client.buildURL('/path/to/image.png', { w: 400, h: 300 });
console.log(url); // => 'https://my-social-network.imgix.net/users/1.png?w=400&h=300&s=…'

In-browser

var client = new ImgixClient({
  host: 'my-social-network.imgix.net'
  // Do not use signed URLs with `secureURLToken` on the client side,
  // as this would leak your token to the world. Signed URLs should
  // be generated on the server.
});

var url = client.buildURL('/path/to/image.png', { w: 400, h: 300 });
console.log(url); // => "https://my-social-network.imgix.net/users/1.png?w=400&h=300"

What is the ixlib param on every request?

For security and diagnostic purposes, we sign all requests with the language and version of library used to generate the URL.

This can be disabled by passing a falsy value for the includeLibraryParam option to new ImgixClient:

new ImgixClient({
  host: 'my-source.imgix.net',
  includeLibraryParam: false
});

Testing

imgix-core-js uses mocha for testing. Here’s how to run those tests:

npm test

Publishing a new version

To publish a new version of the NPM package:

$ npm publish

The Bower package will be automatically updated when you create a new release in GitHub.

imgix-core-js's People

Contributors

kellysutton avatar paulstraw avatar jayeb avatar oaleynik avatar joshfrench avatar nkishorchandra avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.