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 🙏

© 2026 – Pkg Stats / Ryan Hefner

spin-server

v1.1.7

Published

Quickly turn functions and modules into Express API's.

Readme

spin-server converts Functions and Modules to APIs in one line of code!

It preserves the function and variable names and returns a 200 status if there is no error and a 500 if there is an error.

#Installation:

npm install spin-server

#Example:

var spin = require('spin-server')
function hello ( name ) { 	
    return `Hello ${name}!`
}
spin(hello,3000)

This creates an Express Endpoint "/hello" on port 3000 that wants a variable called "name" in the POST or GET data.

Example curl requests:

curl localhost:3000/hello?name=Ryan
Hello Ryan!

curl -d "name=Ryan" localhost:3000/hello
Hello Ryan!

#Anonymous functions:

You can spin anonymous functions up to "/"

spin( function ( name ) { 
    return `Hello ${name}!` 
} , 3000 )

And then send a request to them

curl localhost:3000/?name=Ryan
Hello Ryan!

curl -d "name=Ryan" localhost:3000/
Hello Ryan!

#Modules and Objects:

You can also spin up an object of Functions or a Module

So if you had a file called hello.js

function hello ( name ) { 
    return `Hello ${name}!`
}
function hi ( name ) {
    return `Hi ${name}!`
}

module.exports = { hello, hi }

And then in another file you spun it up

var hello = require('./hello.js')
spin ( hello , 3000 )

You could use the endpoints

 curl -d "name=Ryan" localhost:3000/hello
 Hello Ryan!

 curl localhost:3000/hi?name=Ryan
 Hi Ryan!

#Sessions:

If you need to use session data, simply use "$" in the arguments

function hello ( name, $ ) {
    $.name = name
    return `Hello ${name}!`
}
function who ( $ ) {
    return `You are ${$.name}!`
}
function bye ( $ ) {
    var name = $.name
    delete($.name)
    return `Bye ${name}!`
}

module.exports = { hello, bye }

And then send up some commands

curl localhost:3000/hello?name=Ryan
Hello Ryan!

curl localhost:3000/who
You are Ryan!

curl loalhost:3000/bye
Bye Ryan!

#Errors:

If the function throws an error, the error message is forwarded along with a 500 status

function sorry ( ) { 
    throw `I'm sorry!`
}
function ok () {
    return "okay"
}
spin ( { sorry , ok } , 3000)

Then test it

curl localhost:3000/sorry
I'm sorry!

curl -o /dev/null -s -w "%{http_code}\n" http://localhost:3000/sorry
500

curl localhost:3000/ok
okay

curl -o /dev/null -s -w "%{http_code}\n" http://localhost:3000/ok
200

#Redirects:

If you need to use a redirect, include it with "redirect" as an argument just like you would with session. "redirect" is a function that tells spin-server to redirect to the URL you pass as an argument

function home ( redirect ) {
return redirect ( "/index.html" )
}
spin(home, 3000)

And then call it

curl localhost:3000/home
Found. Redirecting to /index.html

curl -o /dev/null -s -w "%{http_code}\n" http://localhost:3000/home
302

Enjoy!

And if you want to start selling your API in 5 minutes, list it on API Exchange!