Skip to content

Commit 9c9a8e5

Browse files
Manu ChaudharyManu Chaudhary
authored andcommitted
Update readme and type error
1 parent 6ad69f5 commit 9c9a8e5

File tree

12 files changed

+142
-71
lines changed

12 files changed

+142
-71
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules/*
22
samples/sample-app/node_modules/*
3+
.env
34
.vscode
4-
.DS_Store
5+
.DS_Store

Gruntfile.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,25 @@ module.exports = function(grunt) {
1414
}
1515
}
1616
}
17+
},
18+
uglify: {
19+
options: {
20+
mangle: false
21+
},
22+
my_target: {
23+
files: {
24+
'dist/imagekit-min.js': ['dist/imagekit.js']
25+
}
26+
}
1727
}
1828
});
1929

30+
grunt.loadNpmTasks('grunt-contrib-uglify');
31+
2032
grunt.loadNpmTasks('grunt-browserify');
2133

2234
// Default task(s).
23-
grunt.registerTask('default', ['browserify:dist']);
35+
grunt.registerTask('default', ['browserify:dist','uglify']);
2436

2537
};
2638

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Javascript SDK for [ImageKit.io](https://imagekit.io) that implements the client-side upload and URL generation for use in the browser.
88

9-
ImageKit is a complete image optimization and transformation solution that comes with an [image CDN](https://imagekit.io/features/imagekit-infrastructure) and media storage. It can be integrated with your existing infrastructure - storages like AWS S3, web servers, your CDN and custom domain names, allowing you to deliver optimized images in minutes with minimal code changes.
9+
ImageKit is a complete image optimization and transformation solution that comes 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, allowing you to deliver optimized images in minutes with minimal code changes.
1010

1111
This SDK has no dependency.
1212

@@ -37,7 +37,7 @@ var imagekit = new ImageKit({
3737
`publicKey` and `urlEndpoint` are mandatory parameters for SDK initialization.
3838
`authenticationEndpoint` is essential if you want to use the SDK for client-side uploads.
3939

40-
*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*
40+
*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*
4141

4242
## Usage
4343

@@ -96,8 +96,8 @@ The `.url()` method accepts the following parameters
9696
| path | Conditional. This is the path at which the image exists. For example, `/path/to/image.jpg`. Either the `path` or `src` parameter need to be specified for URL generation. |
9797
| src | Conditional. This is the complete URL of an image already mapped to ImageKit. For example, `https://ik.imagekit.io/your_imagekit_id/endpoint/path/to/image.jpg`. Either the `path` or `src` parameter need to be specified for URL generation. |
9898
| transformation | Optional. An array of objects specifying the transformation to be applied in the URL. The transformation name and the value should be specified as a key-value pair in the object. Different steps of a [chained transformation](https://docs.imagekit.io/features/image-transformations/chained-transformations) can be specified as different objects of the array. The complete list of supported transformations in the SDK and some examples of using them are given later. If you use a transformation name that is not specified in the SDK, it gets applied as it is in the URL. |
99-
| transformationPostion | Optional. Default value is `path` that places the transformation string as a path parameter in the URL. Can also be specified as `query` which adds the transformation string as the query parameter `tr` in the URL. If you use `src` parameter to create the URL, then the transformation string is always added as a query parameter. |
100-
| queryParameters | Optional. These are the other query parameters that you want to add to the final URL. These can be any query parameters and not necessarily related to ImageKit. Especially useful, if you want to add some versioning parameter to your URLs. |
99+
| transformationPostion | Optional. The default value is `path` that places the transformation string as a path parameter in the URL. It can also be specified as `query` which adds the transformation string as the query parameter `tr` in the URL. If you use `src` parameter to create the URL, then the transformation string is always added as a query parameter. |
100+
| queryParameters | Optional. These are the other query parameters that you want to add to the final URL. These can be any query parameters and not necessarily related to ImageKit. Especially useful if you want to add some versioning parameter to your URLs. |
101101

102102
#### Examples of generating URLs
103103

@@ -121,7 +121,7 @@ https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=h-300%2Cw-
121121

122122
**2. Sharpening and contrast transforms and a progressive JPG image**
123123

124-
There are some transforms like [Sharpening](https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation) that can be added to the URL with or without any other value. To use such transforms without specifying a value, specify the value as "-" in the transformation object, otherwise, specify the value that you want to be added to this transformation.
124+
There are some transforms like [Sharpening](https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation) that can be added to the URL with or without any other value. To use such transforms without specifying a value, specify the value as "-" in the transformation object. Otherwise, specify the value that you want to be added to this transformation.
125125

126126
```
127127
var imageURL = imagekit.url({
@@ -195,17 +195,17 @@ The SDK provides a simple interface using the `.upload()` method to upload files
195195

196196
The `upload()` method requires `file` and the `fileName` parameter.
197197

198-
Also make sure that you have specified `authenticationEndpoint` during SDK initialization. The SDK makes an HTTP GET request to this endpoint and expects a JSON response with three fields i.e. `signature`, `token` and `expire`.
198+
Also, make sure that you have specified `authenticationEndpoint` during SDK initialization. The SDK makes an HTTP GET request to this endpoint and expects a JSON response with three fields, i.e. `signature`, `token`, and `expire`.
199199

200200
[Learn how to implement authenticationEndpoint](https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload#how-to-implement-authenticationendpoint-endpoint) on your server.
201201

202-
You can pass other parameters supported by the ImageKit upload API using the same parameter name as specified in the upload API documentation. For example, to specify tags for a file at the time of upload use the `tags` parameter as specified in the [documentation here](https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload).
202+
You can pass other parameters supported by the ImageKit upload API using the same parameter name as specified in the upload API documentation. For example, to specify tags for a file at the time of upload, use the `tags` parameter as specified in the [documentation here](https://docs.imagekit.io/api-reference/upload-file-api/client-side-file-upload).
203203

204204
Sample usage
205205
```
206206
<form action="#" onsubmit="upload()">
207-
<input type="file" id="file1" />
208-
<input type="submit" />
207+
<input type="file" id="file1" />
208+
<input type="submit" />
209209
</form>
210210
<script type="text/javascript" src="../dist/imagekit.js"></script>
211211
@@ -237,13 +237,13 @@ Sample usage
237237
</script>
238238
```
239239

240-
If the upload succeed, `err` will be `null` and the `result` will be the same as what is received from ImageKit's servers.
241-
If the upload fails, `err` will be the same as what is received from ImageKit's servers and the `result` will be null.
240+
If the upload succeeds, `err` will be `null`, and the `result` will be the same as what is received from ImageKit's servers.
241+
If the upload fails, `err` will be the same as what is received from ImageKit's servers, and the `result` will be null.
242242

243243

244244
### Demo Application
245245

246-
The fastest way to get started is 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).
246+
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).
247247

248248
To run it:
249249

dist/imagekit-min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/imagekit.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ var transformationUtils = require('../../utils/transformation');
171171
/*
172172
Variables
173173
*/
174-
const TRANSFORMATION_PARAMETER = "tr";
174+
var TRANSFORMATION_PARAMETER = "tr";
175175

176176
module.exports.buildURL = function(opts) {
177177
if(!opts.path && !opts.src) {
@@ -236,7 +236,7 @@ function constructTransformationString(transformation) {
236236
for(var i = 0, l = transformation.length; i < l; i++) {
237237
var parsedTransformStep = [];
238238
for(var key in transformation[i]) {
239-
let transformKey = transformationUtils.getTransformKey(key);
239+
var transformKey = transformationUtils.getTransformKey(key);
240240
if(!transformKey) {
241241
transformKey = key;
242242
}
@@ -3696,9 +3696,9 @@ function request (formData, defaultOptions, callback) {
36963696

36973697
module.exports.uploadFile(formData, function(err, responseSucessText) {
36983698
if (err) {
3699-
console.log(error);
3699+
console.log(err);
37003700
if(typeof callback != "function") return;
3701-
callback(error);
3701+
callback(err);
37023702
} else {
37033703
callback(null, responseSucessText);
37043704
}
@@ -3759,10 +3759,11 @@ function _uploadFile (formData, callback) {
37593759
}
37603760

37613761
module.exports = {
3762-
request,
3762+
request : request,
37633763
generateSignatureToken: _generateSignatureToken,
37643764
uploadFile: _uploadFile,
37653765
}
3766+
37663767
},{}],66:[function(require,module,exports){
37673768
module.exports = function(isError, response, callback) {
37683769
if(typeof callback == "function") {

libs/url/builder.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var transformationUtils = require('../../utils/transformation');
1212
/*
1313
Variables
1414
*/
15-
const TRANSFORMATION_PARAMETER = "tr";
15+
var TRANSFORMATION_PARAMETER = "tr";
1616

1717
module.exports.buildURL = function(opts) {
1818
if(!opts.path && !opts.src) {
@@ -77,7 +77,7 @@ function constructTransformationString(transformation) {
7777
for(var i = 0, l = transformation.length; i < l; i++) {
7878
var parsedTransformStep = [];
7979
for(var key in transformation[i]) {
80-
let transformKey = transformationUtils.getTransformKey(key);
80+
var transformKey = transformationUtils.getTransformKey(key);
8181
if(!transformKey) {
8282
transformKey = key;
8383
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "imagekit-javascript",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "Javascript SDK for using ImageKit.io in the browser",
5-
"main": "index.js",
5+
"main": "dist/index.js",
66
"dependencies": {
77
"lodash": "^4.17.15",
88
"url-polyfill": "^1.1.7"
@@ -12,6 +12,7 @@
1212
"formdata-node": "^2.1.1",
1313
"grunt": "^1.0.4",
1414
"grunt-browserify": "^5.3.0",
15+
"grunt-contrib-uglify": "^4.0.1",
1516
"mocha": "^7.0.1",
1617
"sinon": "^8.1.1"
1718
},

samples/sample-app/views/index.html

Lines changed: 0 additions & 43 deletions
This file was deleted.

samples/sample-app/views/index.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ html
2727
authenticationEndpoint: "!{authenticationEndpoint}"
2828
});
2929

30-
window.imagekit = imageekit;
30+
window.imagekit = imagekit;
3131

3232
function upload(e) {
3333
e.preventDefault();

0 commit comments

Comments
 (0)