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

apier

v1.0.4

Published

Creating APIs can't be easier.

Downloads

20

Readme

apier Build Status

Creating APIs can't be easier.

apier (all lowercase) is a framework that allows the super easy creation of APIs.
It is opinionated based on my experiences with APIs the last 3 years and the structure is inspired by the Foursquare API.

Demo

I created a demo app in the apier-demo repo. Follow the instructions there to setup it up on your own, or just browse the code.

Features

  • Easy Setup
  • Uses standard Node.js style urls
  • Uses Mongoose Schemas
  • Easily support multiple HTTP methods
  • endpoint access based on user roles and public services
  • Supports middlewares
  • Build-in validation system

Setup

The setup and initial configuration is super easy.

var http = require('http');
var apier = require('apier');

// create and configure an apier app
var app = apier({
	mongoUrl: 'mongodb://yourdatabaseurl',
	access: {
		'verifyOrigin': true,
		'apikeys': [{
			'origin': 'http://localhost:3000',
			'key': '1234'
		}]
	},
	handleErrors: true
});

// require the endpoint files
require('./v1/authentications/login.js')(app);

// start the server
http.createServer(app).listen(2000, function() {
	console.log('Server started on port 3000');
});

To configure the apier, you just need to provide the mongoDB url, the access configuration (as explained here) and define if you want apier to automatically handle database errors you want to do it yourself

URLs

The Express.js router is used internally, and so apier supports all the url formats you are used to

Mongoose schemas

apier uses Mongoose to interact with the database. In the future, those will be inside the apier, but right now, you have to create your Mongoose Schemas based on the example found here, which is not that different from the usual mongoose schemas you know, you just have to copy paste the methods found below tha actual schema, and replace 'user' with your schema name.

Also, note the permissions static, that identifies which user roles can see each schema attribute. Permissions explained here

API Endpoints

The following is an example of how we create an API endpoint (a service).

app.endpoint({
	methods: ['get', 'post'],
	url: '/users/:id/update',
	permissions: ['member'],
	middlewares: [validate],
	callback: function(req, res) {
		main(req, res, this);
	}
});

In that example we setup the update service of a user with the specified id (1234)
e.g. service url: 'http://localhost:2000/users/1234/update'

We accept both GET and POST requests.

Only logged in users that are identified with user role 'member' (admin can see anything) can access that service. Don't confuse this with the schema attributes, it's the same logic though.

We will use the validate middleware (explained below) or any other middleware.

And finally assign a callback. We pass 'this' as well to use it to send back data.

Validations

The validations system is better explained here. So, go check it out, but you can decide not to use it, since it's just a middleware, add your own :)

Roadmap

  • Make the schemas easier to create by doing most of the heavy lifting inside apier.

Tests

npm install
npm test

License

MIT