Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

buzzfont

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buzzfont

Your Own Powerful Google Fonts API

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

BuzzFont

Make your own Google Fonts API with some extra features

  • Search by any font quality.
  • Get PNG previews of each font.
  • Generate server side renders of the any text with any font.
  • Automitically updated once a day.
  • Server Agnostic

Examples

  • Get all serif fonts, ordered by popularity.
http://localhost:3000/types?name=serif&orderBy=popularity&dir=desc
  • Search for a specific font by name.
http://localhost:3000/search?name=roboto
  • Get all fonts, alphabetically ordered.
http://localhost:3000/search?orderBy=family&dir=asc

Quick Start

1. Clone this repository:

git clone https://github.com/ClickSimply/buzzfont.git

2. NPM Install

cd buzzfeed && npm i

3. Update Server Details

Open the sample-server.js file and upate the details at the top.

const PORT = 3000;
const PUBLIC_URL = `http://localhost:${PORT}`;
const APIKEY = "YOUR GOOGLE KEY HERE";

4. Run Server

node sample-server.js

The script will generate preview URLs for every font available (over 800), then will start the express server. The example queries above will work from here.

Roll Your Own

The library itself doesn't have any expressJS or other server code. It just handles the indexing of the fonts and other cool stuff.

You can easily embed the library in your own project. The "sample-server.js" file shows a full working example of the script working with express, a smaller example is below.

1. Install BuzzFont

npm i buzzfont --save

2. Integrate With Your App

const BuzzFont = require("buzzfont").BuzzFont;
const express = require("express");
const http = require("http");

const PORT = 3000;
const PUBLIC_URL = `http://localhost:${PORT}`;
const APIKEY = "YOUR GOOGLE KEY HERE";

const fontDB = new BuzzFont({
    apiKey: APIKEY,
    baseURL: PUBLIC_URL,
    ready: () => {
        const app = express();

        // Serve the preview images
        app.use("/previews", express.static("./previews"));

        // Once initilized, the library exposes fontDB.nSQL() as a nanoSQL store containing the fonts
        // Read about how to use nanosql here https://github.com/ClickSimply/Nano-SQL/wiki/2.-Query

        // Handle queries with nanosql
        app.get("/search", (req, res) => { 

            fontDB.nSQL()
                .query("select")
                .where(["family", "LIKE", req.query.name])
                .exec().then((rows) => {
                    res.send(rows).end();
                });

        });

        // Run Server
        http.createServer(app).listen(PORT, () => {
            console.log("Server listening on %d", PORT);
        });
    }
});

Keywords

FAQs

Package last updated on 26 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc