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

spawnpoint

v2.2.1

Published

Agnostic JS framework that empowers devs to focus on quickly building apps, rather than focusing on application config, health-checks, application structure, or architecture to build a 12 factor app in Docker.

Downloads

369

Readme

Spawnpoint Logo npm version dependencies Status Build Status Coverage Status FOSSA Status

Spawnpoint

Agnostic JS framework that empowers devs to focus on quickly building apps, rather than focusing on application config, health-checks, application structure, or architecture to build a 12 factor app in Docker.

Quickstart

This quick demo shows that you can create a basic API in just a couple files that's defined by configuration, but is 12 factor ready, Docker ready, and much more! Check out the full demo here.

npm install spawnpoint --save

// ~/app.js
const spawnpoint = require('spawnpoint');

const app = new spawnpoint();
app.setup();
// ~/config/app.json
{
	"name": "Example App",
	"plugins": [
		"spawnpoint-express", // this creates an express server
		"spawnpoint-redis"	// this establishes a connection to a redis server via redisio
	],
	"autoload": [
		// this autoloads all js files in the ~/controllers folder
		{
			"name": "Controllers",
			"folder": "controllers"
		}
	]
}
// ~/controllers/app.js
module.exports = (app) => {
	// express is already setup and configured via JSON
	app.server.get('/user/:id', (req, res) => {
		// redis is already connected and ready
		app.redis.get(`user:${req.params.id}`, (err, results) => {
			if(err){ res.fail(err); } // automatic error handling

			// return JSON formated success with a success code
			res.success('users.list', {
				user: JSON.parse(results)
			});
		});
	});
};

Plugins

Spawnpoint plugins create opinionated & re-usable components that reduce the code needed to kickstart projects. Plugins are configured via JSON config files, making them easier to share between projects with different needs.

Another JS Framework? Why?

We constantly found our dev team rebuilding the same components to our micro services that make up the Multiplayer Gaming Cloud platform at Nodecraft. Most of the features had blatant copy/paste to ensure our applications could:

  • Building 12 factor apps
  • Auto-loading multiple folders for product folder structure
  • File require() recursion management overhead ?
  • Support basic --command="args" that override config files
  • ENV variables that override config files
  • Docker Secrets that override config files
  • Dev config overrides
  • Rebuilding a basic JSON REST API via express
  • Database connect/reconnect management
  • Healthchecks
  • Application lifecycle
    • Tracks app startup
    • Graceful shutdown
  • Making a Docker friendly NodeJS app

Hoisting app

The most opinionated design choice that Spawnpoint makes is hoisting the entire framework runtime into each file. You can name this variable anything, but the best practice is to name this variable app. All system models, libraries, and config are hoisted to this variable with several namespaces:

app.config

All application config is mounted here. For example app.config.express is where all configuration is available to the spawnpoint-express plugin.

app.status

Tracks the current application lifecycle.

app.containerized

Detects if app is running in a container.

app.cwd

Returns the main folder where your application lives.

Hoisting your own Libraries

When you hoist your library on the app variable you can access it on any other autoloaded js file.

module.exports = (app) => {
	app.yourLibName = {
		add(a, b){
			return a + b;
		}
	};
}
app.server.post('/add', (req, res) => {
	// redis is already connected and ready
	let results = app.yourLibName.add(req.body.a, req.body.b);
	res.success('math.add', {
		results: results
	});
});

Framework Examples

Documentation

Get the full API Docs here.

License

FOSSA Status