Cloudinary
Javascript library for working with Just Eat's Cloudinary service
Installation
npm install @justeat/cloudinary
yarn add @justeat/cloudinary
Usage
Create an instance
import Cloudinary from '@justeat/cloudinary';
const cloudinary = Cloudinary({
tenant: 'uk',
env: 'prod'
});
Tenant
- Set the instance's tenant
- Defaults to
uk
for undefined value
const cloudinary = Cloudinary({ tenant: 'uk' });
Environment
- Set the instance's environment
- Using a non-configured environment throws an
INVALID_ENV
error
const cloudinary = Cloudinary({ env: 'prod' });
Value | Description |
---|
prod | (default) Production |
staging | Staging |
test | Test |
Methods
Please check the source documentation for more detail on how to use the below methods
restaurant: Returns the cloudinary path of a restaurant image
const restaurantId = 2782084;
const opts = {
cuisine: 'thai',
quality: 'auto'
};
const url = cloudinary.restaurant(restaurantId, opts);
dishes: Returns the cloudinary path of a restaurant dish image
const restaurantId = 2782084;
const dishImage = 'assorted-meal.jpg'
const opts = {
quality: 'auto'
};
const url = cloudinary.dishes(restaurantId, dishImage, opts);
url: Returns cloudinary url of restaurant image
const resourcePath = '/path/to/resource.jpg';
const params = {
height: 100,
width: 100
};
const url = cloudinary.url(resourcePath, params);
Development and Testing
Build: npm run build
Lint: npm run lint
Release: npm run release
Single run test: jest
Continuous test: jest --watchAll