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 🙏

© 2025 – Pkg Stats / Ryan Hefner

apified

v0.2.2

Published

Serves Web APIs out of JavaScript functions

Readme

APIfied

Let any JavaScript function to be served as a Web API, in just one line!

Install

npm install atzori/apified

Getting Started

Save the following into a nodejs file (e.g., my_web_api.js):

function mycoolfunction(number, anotherNumber) {
	return number + anotherNumber
}

var apified = require('apified')
apified(mycoolfunction) // your API is online

// or, if you prefer one-line, just use the following instead:
//require('apified')(mycoolfunction)

Then run node my_web_apy.js and bang... your Web API server is up and running!

Checkout the service at http://localhost:3000/mycoolfunction?number=5&anotheNumber=9 and get the valid JSON {"result":"14"}.

Features

apified has a lot of cool features.

  • support all HTTP verbs (including GET and POST)
  • function argument names are recognized and used as get parameter names
  • supports both named and anonymous functions
  • works with async functions (both callback-based and thenable/promises): callbacks are recognized when the last argument of the function is named callback
  • if the output is an object, it will be returned as valid JSON, otherwise a {"result": FUNCTION_RESULT} JSON is returned
  • in case of errors (such as exceptions) an {"error":ERROR_DESCRIPTION_STRING} is returned with HTTP 400
  • it handles argument numbers transparently (converting strings to numbers when appropriate).
  • supports Cross-Origin Resource Sharing (CORS) so the service can also be queried easily from the browser.
  • it even works with sync functions that do not return any value, returing their stdout (console.log) instead
  • parallel execution using multiple workers (can be disabled)

Options

apified(function, [options])

where options may be a string the set the name of the service (overriding the default which is equal to the name of the function). Also useful for anonymous functions or deep paths such as my/cool/service.

Alternatively it can be an object with the following optional parameters:

  • name: the path of the service (default: function name)
  • port: the port used by the service (default: the value in the environment variable PORT, or 3000 if unsed)
  • cors: set/unset CORS (default: true)
  • workers: the number of workers, either an integer >=1 or a boolean; false means one worker, true set the number of workers twice the number of processors (default: true)
  • cache: set/unset the cache (default: false); set a simple in-memory cache (note: there is a different cache for each worker)

Development

npm run devstart 	# run the test example (running the server)
npm test 			# execute a GET request using curl