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

famous-quotes

v1.0.3

Published

An Express wrapper for the "Random Famous Quotes" API found on Mashape.

Downloads

7

Readme

famous-quotes

An Express wrapper for the "Random Famous Quotes" API found on Mashape. Link: https://market.mashape.com/andruxnet/random-famous-quotes

The response body of the GET request to the endpoint will be an object with a quote and author property. See examples for more details.

You may use this for a "quote of the day", at least, that's what I use it for. Or perhaps you could have a button that generates a random quote when clicked. Keep in mind that there are likely rate limits for the API; this wrapper does not limit the number of requests you can make, so please do your own research if you plan to do something request intensive.

Usage

getQuoteMaker(key, options)

  • key (String) The secret key provided by Mashape
  • options (Object)
    • default (Object) The default quote to be shown, if the request fails, for some reason. Below are the relevant properties.
      • quote
      • author
  • Returns (Object) Returns a quoteMaker object (see below).

quoteMaker.getRouter()

  • Returns (Router) Returns an Express router to be used for middleware.

quoteMaker.genQuote(options)

  • options (Object) Properties below.
    • type (String) The quote type. There are two options, the default, 'famous', and 'movies'.
    • count Integer The number of quotes to be returned, with a maximum limit of 100. Defaults to 1.

quoteMaker.getGenerator(refresh, options)

  • refresh (Integer) The amount of delay, in milliseconds, between each .genQuote() call. Defaults to one day.
  • options (Object) The options object to be passed to .genQuote().
  • Returns (setInterval ID) Returns the setInterval ID of the interval that will call .genQuote() every X milliseconds;

Example

const DEFAULT_QUOTE = {
  quote: 'Don\'t let schooling interfere with your education.',
  author: 'Mark Twain'
};
const MASHAPE_KEY = 'SOME_KEY';
const express = require('express');
const quoteMaker = require('famous-quotes')(MASHAPE_KEY, DEFAULT_QUOTE);
const app = express();

// Regenerate a new quote every hour
quoteMaker.getGenerator(1000 * 60 * 60);
app.use('myendpoint', quoteMaker.getRouter());

And on client-side... (I'm using Angular, and omitted some steps; consider it an exercise for the reader to fill in the steps ;))

$http({
  method: 'GET',
  url: 'myendpoint'
}).then(function(res) {
  console.log('Quote: ' + res.data.quote);
  console.log('Author: ' + res.data.author);
}, function(err) {
  console.log(err);
});