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

apinode

v0.2.0

Published

An API server that can greatly reduce the work needed to implment API services. It can also cooperate with other API node to make it a mesh of services.

Downloads

20

Readme

apinode

An API server which can greatly reduce the work when implementing your own API services.

Get Started

It's quite easy to set up your own API server using apinode. Below is a sample code:

var  apiNode = require('apinode');

var  config = {
        appPath: "...",
        logDir: "..."
     };

apiNode.init( config );
apiNode.restart();

Yes, it's that simple. You initialize apinode with a config object, and set sail of it. The configuration usually has at least two properties: the "appPath" property specifying where is your application code and the "logDir" specifying the log directory where apinode will dump its output log.

Write Your Own Service

To start with, let's depict the file structure of a typical apinode project:

+ lib
  + app
    + _api
    + app_1
      + resource_1
        + op_1
        + op_2
      + resource_2
      + ...
    + app_2
    + ... app_n

The enpoints served by apinode are formulated as app/resource/op. For example, admin/user/login is a built-in service endpoint of apinode. If you want to create an endpoint as blog/article/list, you should create a listOp.js file under the lib/app/blog/article directory.

The Operator

The actual API services should be provided by operators. An operator is a node module which should be saved in the lib/app/your_app/your_resource directory so it can be found and invoked by apinode. An operator should at least define a run() function to offer the intended service. Below is a very simple example:

exports.fun = function(rt, cb)  {
    this.answerOk('Hello There!', cb);
}

The rt parameter carries the run-time environment and cb is the callback function to indicate an operator has finished its job. Since this is a very short introduction, we'll not touch too many ground. The apinode module itself contains a built-in app called "admin" which is under the lib/app/admin direcoty. You can browse through that direcoty and find quite a few operator examples.