Skip to content

Commit 21f0347

Browse files
committed
version bump, changelog and readme update
1 parent 1436f0a commit 21f0347

File tree

7 files changed

+59
-62
lines changed

7 files changed

+59
-62
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [1.3.1]
5+
- Only urlEndpoint is required during SDK initilization
6+
47
## [1.0.1] - 01 Nov 2019
58
- Removed jQuery dependency.

README.md

Lines changed: 51 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
[<img width="250" alt="ImageKit.io" src="https://raw.githubusercontent.com/imagekit-developer/imagekit-javascript/master/assets/imagekit-light-logo.svg"/>](https://imagekit.io)
2+
13
# ImageKit.io Javascript SDK
24

5+
![gzip size](https://img.badgesize.io/https://unpkg.com/imagekit-javascript/dist/imagekit.min.js?compression=gzip&label=gzip)
6+
![brotli size](https://img.badgesize.io/https://unpkg.com/imagekit-javascript/dist/imagekit.min.js?compression=brotli&label=brotli)
37
![Node CI](https://github.com/imagekit-developer/imagekit-javascript/workflows/Node%20CI/badge.svg)
48
[![npm version](https://img.shields.io/npm/v/imagekit-javascript)](https://www.npmjs.com/package/imagekit-javascript)
59
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
610
[![Twitter Follow](https://img.shields.io/twitter/follow/imagekitio?label=Follow&style=social)](https://twitter.com/ImagekitIo)
711

8-
Javascript SDK for [ImageKit.io](https://imagekit.io) that implements the client-side upload and URL generation for use in the browser.
9-
10-
ImageKit is a complete image optimization and transformation solution with an [image CDN](https://imagekit.io/features/imagekit-infrastructure) and media storage. It can be integrated with your existing infrastructure - storage like AWS S3, web servers, your CDN, and custom domain names. It allows you to deliver optimized images in minutes with minimal code changes.
12+
ImageKit Javascript SDK allows you to use real-time [image resizing](https://docs.imagekit.io/features/image-transformations), [optimization](https://docs.imagekit.io/features/image-optimization), and [file uploading](https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload) in the client-side.
1113

12-
This SDK has no dependency.
14+
This SDK is lightweight and has no dependency. You can also use this as an ES module.
1315

1416
## Installation
1517

@@ -33,7 +35,7 @@ You can download a specific version of this SDK from a global CDN.
3335
https://unpkg.com/[email protected]/dist/imagekit.min.js
3436
```
3537

36-
For latest version remove the version number i.e.
38+
For the latest version, remove the version number i.e.
3739
```
3840
https://unpkg.com/imagekit-javascript/dist/imagekit.min.js
3941
```
@@ -46,32 +48,38 @@ Now load it using a `<script>` tag.
4648

4749
## Initialization
4850

51+
`urlEndpoint` is required to use the SDK. You can get URL-endpoint from your ImageKit dashboard - https://imagekit.io/dashboard#url-endpoints
52+
4953
```
5054
var imagekit = new ImageKit({
51-
publicKey : "your_public_api_key",
52-
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id",
53-
authenticationEndpoint : "http://www.yourserver.com/auth",
55+
urlEndpoint: "https://ik.imagekit.io/your_imagekit_id"
5456
});
5557
```
5658

57-
`publicKey` and `urlEndpoint` are mandatory parameters for SDK initialization.
58-
`authenticationEndpoint` is essential if you want to use the SDK for client-side uploads.
59+
`publicKey` and `authenticationEndpoint` parameters are required if you want to use the SDK for client-side file upload. You can get these parameters from the developer section in your ImageKit dashboard - https://imagekit.io/dashboard#developers
60+
```
61+
var imagekit = new ImageKit({
62+
publicKey: "your_public_api_key",
63+
urlEndpoint: "https://ik.imagekit.io/your_imagekit_id",
64+
authenticationEndpoint: "http://www.yourserver.com/auth",
65+
});
66+
```
5967

6068
*Note: Do not include your Private Key in any client-side code, including this SDK or its initialization. If you pass the `privateKey` parameter while initializing this SDK, it throws an error*
6169

6270
## Demo Application
6371

64-
The fastest way to get started is by running the demo application. You can run the code locally. The source code is in [samples/sample-app](https://github.com/imagekit-developer/imagekit-javascript/tree/master/samples/sample-app).
65-
66-
To run it:
72+
The fastest way to get started is by running the demo application in [samples/sample-app](https://github.com/imagekit-developer/imagekit-javascript/tree/master/samples/sample-app) folder. Follow these steps to run the application locally:
6773

6874
```
6975
git clone https://github.com/imagekit-developer/imagekit-javascript.git
7076
7177
cd imagekit-javascript
7278
```
7379

74-
Create a file `.env` using `sample.env` in the directory `samples/sample-app` and fill in your `PRIVATE_KEY`, `PUBLIC_KEY` and `URL_ENDPOINT` from your [imageKit dashboard](https://imagekit.io/dashboard#developers). The just run:
80+
Create a file `.env` using `sample.env` in the directory `samples/sample-app` and fill in your `PRIVATE_KEY`, `PUBLIC_KEY` and `URL_ENDPOINT` from your [imageKit dashboard](https://imagekit.io/dashboard#developers).
81+
82+
Now start the sample application by running:
7583

7684
```
7785
yarn startSampleApp
@@ -88,11 +96,11 @@ This method allows you to create a URL using the `path` where the image exists a
8896

8997
```
9098
var imageURL = imagekit.url({
91-
path : "/default-image.jpg",
92-
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/endpoint/",
93-
transformation : [{
94-
"height" : "300",
95-
"width" : "400"
99+
path: "/default-image.jpg",
100+
urlEndpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/",
101+
transformation: [{
102+
"height": "300",
103+
"width": "400"
96104
}]
97105
});
98106
```
@@ -110,10 +118,10 @@ This method allows you to add transformation parameters to an existing, complete
110118

111119
```
112120
var imageURL = imagekit.url({
113-
src : "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg",
114-
transformation : [{
115-
"height" : "300",
116-
"width" : "400"
121+
src: "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg",
122+
transformation: [{
123+
"height": "300",
124+
"width": "400"
117125
}]
118126
});
119127
```
@@ -141,15 +149,15 @@ The `.url()` method accepts the following parameters
141149
**1. Chained Transformations as a query parameter**
142150
```
143151
var imageURL = imagekit.url({
144-
path : "/default-image.jpg",
145-
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/endpoint/",
146-
transformation : [{
147-
"height" : "300",
148-
"width" : "400"
152+
path: "/default-image.jpg",
153+
urlEndpoint: "https://ik.imagekit.io/your_imagekit_id/endpoint/",
154+
transformation: [{
155+
"height": "300",
156+
"width": "400"
149157
}, {
150-
"rotation" : 90
158+
"rotation": 90
151159
}],
152-
transformationPosition : "query"
160+
transformationPosition: "query"
153161
});
154162
```
155163
```
@@ -162,12 +170,12 @@ There are some transforms like [Sharpening](https://docs.imagekit.io/features/im
162170

163171
```
164172
var imageURL = imagekit.url({
165-
src : "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg",
166-
transformation : [{
167-
"format" : "jpg",
168-
"progressive" : "true",
169-
"effectSharpen" : "-",
170-
"effectContrast" : "1"
173+
src: "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg",
174+
transformation: [{
175+
"format": "jpg",
176+
"progressive": "true",
177+
"effectSharpen": "-",
178+
"effectContrast": "1"
171179
}]
172180
});
173181
```
@@ -251,23 +259,23 @@ Sample usage
251259
authenticationEndpoint should be implemented on your server. Learn more here - https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload#how-to-implement-authenticationendpoint-endpoint
252260
*/
253261
var imagekit = new ImageKit({
254-
publicKey : "your_public_api_key",
255-
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id",
256-
authenticationEndpoint : "http://www.yourserver.com/auth"
262+
publicKey: "your_public_api_key",
263+
urlEndpoint: "https://ik.imagekit.io/your_imagekit_id",
264+
authenticationEndpoint: "http://www.yourserver.com/auth"
257265
});
258266
259267
// Upload function internally uses the ImageKit.io javascript SDK
260268
function upload(data) {
261269
var file = document.getElementById("file1");
262270
imagekit.upload({
263-
file : file.files[0],
264-
fileName : "abc1.jpg",
265-
tags : ["tag1"]
271+
file: file.files[0],
272+
fileName: "abc1.jpg",
273+
tags: ["tag1"]
266274
}, function(err, result) {
267275
console.log(arguments);
268276
console.log(imagekit.url({
269277
src: result.url,
270-
transformation : [{ height: 300, width: 400}]
278+
transformation: [{ height: 300, width: 400}]
271279
}));
272280
})
273281
}

assets/imagekit-light-logo.svg

Lines changed: 1 addition & 0 deletions
Loading

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "imagekit-javascript",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Javascript SDK for using ImageKit.io in the browser",
55
"main": "dist/imagekit.cjs.js",
66
"module": "dist/imagekit.esm.js",

samples/sample-app/index.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@ const open = require('open');
33
const dotenv = require('dotenv').config({path: path.join(__dirname, ".env")});
44
const server = require('./server/server.js');
55

6-
7-
const STATIC_PAGE = path.join(__dirname, "client/index.html")
8-
96
if (dotenv.error) {
107
throw new Error(dotenv.error);
11-
process.exit(1);
128
}
139

1410
const {PRIVATE_KEY, PUBLIC_KEY, URL_ENDPOINT, SERVER_PORT} = dotenv.parsed;
@@ -24,16 +20,15 @@ server
2420
try {
2521
return open(`http://localhost:${SERVER_PORT}`, {wait: true});
2622
} catch (err){
27-
console.error(JSON.stringify(err, undefined, 2))
28-
throw new Error(`Error opening the static page ${STATIC_PAGE}.`)
23+
console.error(JSON.stringify(err, null, 2))
2924
}
3025
})
3126
.then(() => {
3227
console.log("Exiting app.");
3328
process.exit(0);
3429
})
3530
.catch(err => {
36-
console.log("Error:", JSON.stringify(err, undefined, 2));
31+
console.log("Error:", JSON.stringify(err, null, 2));
3732
process.exit(1);
3833
});
3934

samples/sample-app/server/server.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,6 @@ const startServer = (port = 3000, PUBLIC_KEY, PRIVATE_KEY, URL_ENDPOINT) => {
2929

3030
const signatureObj = imagekit.getAuthenticationParameters(token, expiration);
3131

32-
// Alternate method for genrating signature
33-
/*
34-
const crypto = require('crypto');
35-
const signatureObj = {
36-
token,
37-
expire: expiration,
38-
signature :crypto.createHmac('sha1', privateAPIKey).update(token+expire).digest('hex')
39-
}
40-
*/
41-
4232
res.status(200).send(signatureObj);
4333

4434
} catch (err) {

samples/sample-app/views/index.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ html
3636
statusEl.innerHTML = "Uploading..."
3737
imagekit.upload({
3838
file : file.files[0],
39-
fileName : "test_image.jpg",
39+
fileName : file.files[0].name || "test_image.jpg",
4040
tags : ["test_tag_1"]
4141
}, function(err, result) {
4242
if (err) {

0 commit comments

Comments
 (0)