A library for Granny image delivery server
granny-server-backend - Backend service with API exposed to upload and serve/manipulate images
granny-js-client - Client library that works both in nodejs and browser. Makes API calls easier
granny-server-frontend - Frontend APP that uses client to manage your CDN domains and settings
granny-server-cron - Utility app
This library can be used in both nodejs and browser environment. Browser clint made only for staging or admin panel development, because you can expose your credentials in browser.
NPM
npm i granny
Building from source
git clone git@github.com:mrspartak/granny-js-client.git
cd granny-js-client
//if you need browser version
npm run build
//request to your browser build/index.js
//if you need nodejs version it is stored in src/index.js
Nodejs
const Granny = require('granny')
const grannyApi = new Granny({
domain: 'https://cdn.example.com', //url to Granny server backend
accessKey: 'key',
accessSecret: 'secret'
})
var [err, result] = await grannyApi.uploadImage({path: '/users/sergio.jpeg', image: './tmp/DSCF6278.jpg'})
console.log(result.imageUrl)
/*
result.imageUrl = https://cdn.example.com/i/users/sergio.jpeg
Now you can use direct link or modify image on fly
https://cdn.example.com/i/r=100/_/users/sergio.jpeg - will resize image to 100x100
https://cdn.example.com/i/width=500,format=webp/_/users/sergio.jpeg - will resize to width=500 saving aspect ratio and format to webp
*/
Currently here: https://github.com/mrspartak/granny-js-client/blob/master/API.md