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

pine.js

v1.0.3

Published

A restful framework inspired by loopback

Readme

Pine.js

pine.js is a tiny framework to help you load strcuture koa application.

Overview

Application code structure:

  • root
    • index.js
    • conf
      • config.default.js
      • config.prod.js
    • app
      • controller
      • service
      • model
      • router.js
    • package.json

Pine.js framework will load config,model,controller and service automatically based on the structure. You don't need require the dependency by youself, framework will load it and inject dependency to your code.

More detail, please look at below example code, just have fun!

Installation

pine.js requires node v7.6.0 or higher for ES2015 and async function support.

$ npm install pine.js

Run example app

git clone https://github.com/frankliu/pinejs-examples.git
cd pinejs-examples
npm install
node index.js

How to use it

1. Create application structure
mkdir app conf logs
mkdir app/controller app/service app/model
touch package.json
npm install --save pine.js
2. Initialize Application(app.js)
const Application = require('pine.js');

const app = new Application({
  baseDir: process.cwd(),
  excludes: {
    controller: ['index.js'],
    service: ['index.js']
  }
})

app.start();
3. add a router(app/router.js)
'use strict';

module.exports = (app) => {
  app.get('/', 'home.index');
  app.get('/user/:loginname', 'user.show');

};
4. add a controller(app/controller/user.js)
const assert = require('assert');

class UserController {
  async show (ctx, next){
    let loginName = ctx.params.loginname;
    this.app.logger.info('getUserByLoginName: %s', loginName);
    let user = await this.app.service.User.getUserByLoginName(loginName);
    ctx.body = user || {};
  }
}

module.exports = UserController;
5. add a service
const assert = require('assert');

class UserService {
  /**
   * 根据登录名查找用户
   * Callback:
   * - err, 数据库异常
   * - user, 用户
   * @param {String} loginName 登录名
   */
  getUserByLoginName (loginName) {
    return this.app.model.User.findOne({'loginname': new RegExp('^'+loginName+'$', "i")});
  }
}

module.exports = UserService;
6. add a model
'use strict';

const BaseModel = require("./base_model");
const pine = require('pine.js');

class UserModel extends pine.Model {
  constructor(options){
    super(options);
    this.defineSchema({
      name: { type: String},
      loginname: { type: String},
      pass: { type: String },
      email: { type: String},
      url: { type: String }
    });
    this.index({loginname: 1}, {unique: true});
    this.index({email: 1}, {unique: true});
    this.pre('save', function(next){
      var now = new Date();
      this.update_at = now;
      next();
    });
  }
}

module.exports = UserModel;
7. start app

node app.js

Framework will inject app to this when load controller, service and model.