npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

express-iconify

v0.0.6

Published

An express sub app for iconify, can also be used directly as a server

Downloads

421

Readme

Express Iconify Server

A lightweight Express.js server for serving Iconify icons.

English Doc | 中文文档

Overview

This project provides a simple and efficient way to serve Iconify icons using Express.js. It allows you to easily integrate Iconify icons into your web applications.

Usage

1. Integration with External Express Project

Install the express-iconify, run the following command:

# npm
npm install express-iconify

# yarn
yarn add express-iconify

# pnpm
pnpm add express-iconify

You can import the Iconify server into your external Express project and mount it using the mountIconify function.

mountIconify

mountIconify is a function that mounts the Iconify server to your Express application. It takes two arguments:

  • app: An Express application instance.
  • option: An optional options object that configures the behavior of mountIconify.
Options
  • path: The path to mount the iconify app, default is /iconify.
  • cache: Whether to cache the icon data in memory. Default is true.
  • cacheMaxSize: The maximum size of the cache. Default is 10000.
  • enableLastModified: Whether to set the Last-Modified header. Default is true.
  • enableCORS: Whether to enable CORS. Default is false.
  • download: Whether to serve the icon as an attachment. Default is false.
Returns

The mountIconify function returns the Express application instance with the Iconify server mounted.

Example
import express from "express";
import { mountIconify } from "express-iconify";

const app = express();

// Mount Iconify server to /icons path
mountIconify(app, { path: "/icons" });

app.listen(3000, () => {
  console.log("Server started on port 3000");
});

In this example, the Iconify server is mounted to the /icons path.

2. Standalone Server

Install the dependencies first, run the following command:

npm install

To build and start the server, run the following command:

npm build
npm start

The server will listen on port 80 by default. You can change the port by setting the PORT environment variable.

API Endpoints

The server provides a single API endpoint for serving icons:

GET /:iconSet/:iconName
  • iconSet: The name of the Iconify icon set (e.g. "mdi")
  • iconName: The name of the icon (e.g. "account")

You can also specify additional query parameters to customize the icon:

  • width: The width of the icon (e.g. "24")
  • height: The height of the icon (e.g. "24")
  • color: The color of the icon (e.g. "#333")
  • rotate: The rotation of the icon (e.g. "90deg")
  • flip: The flip direction of the icon (e.g. "horizontal")
  • box: Whether to add a bounding box around the icon (e.g. "true")
  • download: Whether to download the icon as an attachment (e.g. "true")

Example:

GET /:iconSet/:iconName?width=24&height=24&color=%23333&rotate=90deg

This would retrieve an icon with a width and height of 24 pixels, a color of #333, and rotated 90 degrees.

License

This project is licensed under the MIT License.