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

mkbugjs

v1.5.5

Published

An OOP style declare Nodejs Web framework base on Express.js

Downloads

64

Readme

NPM version NPM quality npm download build status

mkbug.js

An OOP style declare Nodejs framework base on Express.js!

官方文档(中文)

What is mkbug.js

An OOP Style Restful Api framewrok base on Express.js,and make Nodejs development beautiful and easy.

Mkbug.js VS Egg.js VS Think.js

| 项目 | Mkbug.js | Egg.js | Think.js | | ---- | ---- | ---- | ---- | | Nodejs | Nodejs 10+ | Nodejs 8+ | Nodejs 6+ | | Base on | Express.js | Koa.js | Koa.js | | Router | Auto | Manual | Auto | | Plugin | Auto | Manual | Manual | | Middleware | Auto+Manual | Manual | Manual | | Config | Auto | No | No | | JS extend | ES6 | ES6 | Babel | | Style | OOP | Pure | Pure | | Duration | Yes | No | No | | Extend Capability | compatible expressjs | egg ecology | compatible koa |

Your First Mkbug Application

  // index.js
  const express = require('express');
  const app = express();

  const { Mkbug } = require('mkbugjs');

  new Mkbug(app)
    .create('/') // 请求url前缀
    .use(bodyParser.json()) // 使用express中间件
    .start(3001, (err) => { // 启动,同app.listen
    if (!err)
      console.log('Server started!')
    else
      console.error('Server start failed!')
  })

  // src/controller/index.js
  const { BaseController } = require('mkbugjs');

  module.exports = class api extends BaseController {
    getAction () {
      return 'Hello World';
    }
  }

About extends

If you want to use middleware like koa. you can use it like this.

  // base/ControllerBaseBase.js
  const { BaseController } = require('mkbug.js');

  module.exports = class ControllerBaseBase extends BaseController {
    before (req) {
      console.log("ControllerBaseBase before")
    }

    after(){
      console.log("ControllerBaseBase after")
    }
  }

  // base/ControllerBase.js
  const ControllerBaseBase = require('./ControllerBaseBase');

  module.exports = class ControllerBase extends ControllerBaseBase {
    before (request, response) {
      super.before(request, response)
      console.log("ControllerBase before")
    }

    after ({ duration, status, originalUrl, request, response }) {
      console.log("ControllerBase after")
      super.after({ duration, status, originalUrl, request, response })
    }
  }

  // ExtendsTest.js
  const ControllerBase = require('./base/ControllerBase');

  module.exports = class ExtendsTest extends ControllerBase {
    before (request, response) {
      super.before(request, response)
      console.log("Request start")
    }

    getAction () {
      return "hello world"
    }

    after () {
      console.log("Request end")
      super.after({})
    }
  }

And then you can send curl request to /api/extendstest, you should get the log:

  $ curl http://localhost:3000/api/extendstest

  ControllerBaseBase before
  ControllerBase before
  Request start
  Request end
  ControllerBase after
  ControllerBaseBase after

It is very easy, right?