Registry / http-networking / rfg-api

rfg-api

JSON →
library0.5.3jsnpmunverified

The `rfg-api` package provides a Node.js client for the RealFaviconGenerator's non-interactive API, enabling programmatic generation of favicons for various platforms including desktop browsers, iOS, and Android. Currently at version 0.5.3, the library focuses on integrating with the external API to manage favicon creation and asset generation. Release cadence appears to be driven primarily by bug fixes and dependency updates, particularly addressing security vulnerabilities in underlying HTTP clients and archive processors, rather than frequent new feature introductions. Its primary differentiator is its direct integration with the RealFaviconGenerator service, simplifying the complex process of generating a comprehensive set of favicons from a single master image. It largely operates using a callback-based asynchronous pattern.

npm install rfg-api
INSTALL
IMPORT
SIG · RFG-API
R
rfg-api
http-networkingjavascriptv0.5.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

rfgApi
const rfgApi = require('rfg-api').init();
import rfgApi from 'rfg-api'; // ESM not supported
The library primarily uses CommonJS `require` and requires calling `.init()` to get the API client instance. ESM imports are not directly supported given its age and module pattern.
createFavicon
rfgApi.createFavicon(masterPicture, outputPath, design, settings, versioning, apiKey, callback);
require('rfg-api').createFavicon(...); // Must call .init() first to get the instance
The `createFavicon` method is available on the initialized API client instance, not directly on the module export. It uses a callback-based asynchronous pattern.
init
const client = require('rfg-api').init();
const client = require('rfg-api'); // client is the module export, not the initialized API instance
The main module export is a factory function; you must call `.init()` on it to obtain the configured API client object for making requests.

Demonstrates how to initialize the `rfg-api` client, provide a placeholder master image path and API key, and call the `createFavicon` method with a callback to handle the asynchronous response for favicon generation.

const rfgApi = require('rfg-api').init(); const path = require('path'); const fs = require('fs'); const API_KEY = process.env.RFG_API_KEY || 'YOUR_REAL_API_KEY_HERE'; // Replace with your actual key const MASTER_PICTURE_PATH = path.join(__dirname, 'master-image.png'); const OUTPUT_PATH = path.join(__dirname, 'favicons'); // Ensure a dummy master-image.png exists for the example to run. // In a real application, replace this with your actual image path. if (!fs.existsSync(MASTER_PICTURE_PATH)) { console.warn(`Warning: '${MASTER_PICTURE_PATH}' not found. Creating a dummy file.`); // For demonstration, create a minimal dummy file if it doesn't exist fs.writeFileSync(MASTER_PICTURE_PATH, Buffer.from('<svg width="100" height="100"></svg>', 'utf8')); } const faviconConfiguration = { design: { ios: { pictureMargin: 2, backgroundColor: '#ffffff', themeColor: '#ffffff' }, android: { backgroundColor: '#ffffff', themeColor: '#ffffff', pictureMargin: 2 }, desktopBrowser: {} }, settings: { compression: 5, scalingAlgorithm: 'Mitchell', errorOnImageTooSmall: false, readmeFile: false, htmlCodeFile: false }, versioning: {} }; rfgApi.createFavicon( MASTER_PICTURE_PATH, OUTPUT_PATH, faviconConfiguration.design, faviconConfiguration.settings, faviconConfiguration.versioning, API_KEY, (error, response) => { if (error) { console.error('Error generating favicons:', error); return; } console.log('Favicons generated successfully!'); console.log('Response:', JSON.stringify(response, null, 2)); // The response typically contains a zip URL and HTML markups. // You would typically download the zip from 'response.favicon.url' // and inject 'response.favicon.html_code' into your HTML templates. } ); console.log('Initiating favicon generation process...');
Debug
Known issues
breakingThe `injectFaviconMarkups` method signature changed significantly in version 0.1.0. It now expects the HTML content directly as a string, rather than a file path to be read.
fix
Update any calls to `injectFaviconMarkups` to pass the HTML content as a string directly, instead of a file name.
affects: >=0.1.0
gotchaMultiple minor versions (e.g., 0.4.0, 0.5.0, 0.5.1, 0.5.2, 0.5.3) involved significant internal dependency swaps (e.g., `node-rest-client` to `axios`, `unzip` to `unzip2` to `node-unzip-2`) primarily to address security vulnerabilities. While these were internal, users relying on specific behaviors or deeply inspecting network requests might observe changes.
fix
Ensure your environment's Node.js version is compatible and review any custom patching or network monitoring that might be affected by underlying HTTP client changes. Regularly run `npm audit fix` to address known vulnerabilities in dependencies.
affects: >=0.4.0
gotchaThis library critically relies on an external API key from RealFaviconGenerator. The `createFavicon` function will fail without a valid key, often returning an 'API key is missing or invalid' error.
fix
Obtain an API key from RealFaviconGenerator.net and provide it as the `apiKey` argument to `createFavicon`. It's recommended to load this key from environment variables (e.g., `process.env.RFG_API_KEY`) rather than hardcoding.
affects: >=0.0.1
gotchaThe package officially supports Node.js >= 0.8.0, indicating an older codebase that primarily uses callback-based asynchronous patterns and may not fully leverage modern Node.js features like Promises or async/await syntax.
fix
Adapt your code to the callback-based asynchronous pattern for API interactions. If integrating into a modern async/await codebase, consider wrapping the API calls in Promises (e.g., using `util.promisify` for Node.js built-in callback-style functions) or creating a custom Promise wrapper.
affects: >=0.0.1
Errors
Common errors & fixes
Error: API key is missing or invalid
The `apiKey` parameter passed to `createFavicon` is either missing, null, undefined, or contains an incorrect value.
fix
Ensure you have obtained a valid API key from RealFaviconGenerator.net and correctly pass it as the `apiKey` argument to `createFavicon`.
Error: ETIMEDOUT | Error: ENOTFOUND | Error: getaddrinfo ENOTFOUND api.realfavicongenerator.net
Network connectivity issues preventing the client from reaching the RealFaviconGenerator API endpoint, or the API endpoint URL itself is incorrect or temporarily unavailable.
fix
Check your internet connection, verify the RealFaviconGenerator service status page, and ensure no firewalls or proxies are blocking outbound access to `api.realfavicongenerator.net`.
Error: master_picture has an invalid value: ...
The `masterPicture` argument provided to `createFavicon` is not a valid file path, the file does not exist at the specified path, or the image content itself is corrupt or an unsupported format.
fix
Ensure `masterPicture` points to an existing, accessible, and valid image file (e.g., PNG, JPEG, SVG) on the filesystem, or is a correctly formatted base64 encoded image string.
Upgrade
Version history
0.5.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
rfg-api — npm install rfg-api · libregistry