Socket
Book a DemoInstallSign in
Socket

bifroster-framework-koa-loader

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bifroster-framework-koa-loader

bifroster-framework-koa

1.0.2
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Koa framework

基于Koa的应用架构。

Install

npm install --save bifroster-framework-koa-loader

Usage

app.js

module.exports = require('bifroster-framework-koa-loader').bootstrap({
  service: {
    directory: 'service',
    match: ['**/*.js'],
    ignore: null,
    override: true
  },
  constroller: {
    directory: 'service',
    match: ['**/*.js'],
    ignore: null,
    override: true
  },
  middleware: {
    directory: 'service',
    match: ['**/*.js'],
    ignore: null,
    override: true
  },
  router: 'router'
});

Service Controller and Middleware Layer Usage

app/service/index-test-value.js

const { Service } = require('bifroster-framework-koa-loader');
module.exports = class testService extends Service {
  constructor(app) {
    super(app);
  }
  value() {
    return 2;
  }
}

Invoke:

app.Service.indexTestValue;
app.Service.indexTestValue.value(); // 2

Router auto layer

app/router/index.js:

module.exports = (app,router) => {
  router.get('/', app.Controller.indexControllerTest.hello);
}

app/router/test.js:

module.exports = (app, router) => {
  router.get('/', app.Controller.indexControllerTest.hello);
  router.get('/:id(\\d+)/user', app.Controller.indexControllerTest.b);
}

系统自动根据目录结构生成路由嵌套逻辑。

性能

所有执行都是服务启动前所做的,所以性能方面与一般KOA性能相同。不需要担心性能问题。

FAQs

Package last updated on 29 Dec 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.