
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
An OOP style declare Nodejs framework base on Express.js!
An OOP Style Restful Api framewrok base on Express.js,and make Nodejs development beautiful and easy.
项目 | 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 |
// 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';
}
}
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?
FAQs
An OOP style declare Nodejs Web framework base on Express.js
The npm package mkbugjs receives a total of 7 weekly downloads. As such, mkbugjs popularity was classified as not popular.
We found that mkbugjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.