Node.js SDK
Server-side SDK for imgfast image management.
download
Installation
npm install @imgfast/node
# or with yarn
yarn add @imgfast/nodesettings
Configuration
import { Imgfast } from '@imgfast/node';
const imgfast = new Imgfast({
publicKey: process.env.IMGFAST_PUBLIC_KEY,
secretKey: process.env.IMGFAST_SECRET_KEY,
signingSecret: process.env.IMGFAST_SIGNING_SECRET, // optional
});upload
Upload Images
From File
import fs from 'fs';
const file = fs.readFileSync('./photo.jpg');
const result = await imgfast.upload({
file,
filename: 'products/sneaker-01.jpg',
contentType: 'image/jpeg',
});
console.log(result.cdnUrl);
// https://cdn.imgfast.io/pk_xxx/products/sneaker-01.jpgFrom Buffer/Stream
// From Express multer
app.post('/upload', async (req, res) => {
const result = await imgfast.upload({
file: req.file.buffer,
filename: req.file.originalname,
contentType: req.file.mimetype,
});
res.json({ url: result.cdnUrl });
});link
Generate URLs
// Basic URL
const url = imgfast.url('products/sneaker-01.jpg');
// With transformations
const transformedUrl = imgfast.url('products/sneaker-01.jpg', {
width: 400,
height: 300,
format: 'webp',
quality: 80,
fit: 'cover',
});
// Remote URL proxy
const proxyUrl = imgfast.proxyUrl('https://example.com/image.jpg', {
width: 800,
format: 'auto',
});verified_user
Signed URLs
// Generate signed URL (requires signingSecret)
const signedUrl = imgfast.signedUrl('products/sneaker-01.jpg', {
width: 400,
format: 'webp',
expiresIn: 3600, // 1 hour
});
// Verify signature
const isValid = imgfast.verifySignature(url);info
Signed URLs require the signing secret from your dashboard Settings → Signed URLs.