Giter Club home page Giter Club logo

salak-core's Introduction

salak-core

NPM version build status David deps NPM download

Deprecated,move to salak

salak核心库,基于koa 2.0

不建议直接使用salak-core,可以直接使用 salak

特性

  • 自动路由,根据controller生成service
  • 中间件扩展,可以自定义中间件执行顺序
  • Joi校验,增强代码健壮性,提供路由执行前参数校验以及输出校验
  • 日志插件,基于winston

用法

目录结构

├── common
│   ├── config
│   │   └── default.js
│   └── middleware
│       └── error.js
├── blog
│   ├── config
│   │   └── default.js
│   ├── controller
│   │   ├── comment.js
│   │   └── post.js
│   ├── middleware
│   │   ├── auth.js
│   │   └── err.js
│   └── service
│       └── post.js
└── index.js

安装

npm install --save salak-core

编写controller

const { Controller } = require('salak-core')

class Post extends Controller {
  actionIndex () {
    this.ctx.body = 'hello, Post.'
  }
}

默认会注册/post 路由

API

SalakCore

constructor (options)

  • {Object} options - 配置
  • {String} options.baseDir - 项目根目录
  • {Object} options.opts - 其他设置
  • {String} options.opts.root - common目录命名,默认为common

router

salak-router 实例

loader

SalakCoreLoader 实例

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.