Servo
An image resizing service to sit behind a dynamic cache (like CloudFront).
Install
Install Servo with npm.
npm install -g servo
Set up your configuration (see below) and simply run
SERVO_CONFIG=/my/config.js servo
Config
Servo uses a JS/JSON file for configuration that needs to be passed in through a
SERVO_CONFIG
environment variable.
sample servo.json
Requests
Servo responds to a few requests.
request
GET /path/to/resource[-routine][.extension]
[?servoKey=servoKey[&ttl=seconds][&filename=contentDispositionFilename]]
No authentication is required for this request. If specific image at the requested size and extension has yet to be generated, it will be generated on the fly, otherwise the cloudfront cache should catch it. If authenticated, will redirect to a signed URL for the requested resource.
response
(requested resource or empty body and error status code)
request
PUT /[explicit route]
servoKey=servoKey
(file=@imgA.jpg) OR (key=s3Key [bucket=default-bucket])
routine=strip;scale:100,100 (optional)
A Servo Key is required in the header of the request to PUT resources into S3.
When an explicit route is not specified, files are saved as their hashed value.
The resource mime type is extracted from the file's extension and stored as a
header in S3. An optional routine
option may be added to put the image through
a series of GraphicsMagick operations before uploading.
response
request
DELETE /path/to/resource
servoKey=servoKey
A Servo Key is required in the header of the request to DELETE resources in S3. The request simply returns a 200 status and empty JSON object on success.
response
204 No Content