Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thinkjs/think-controller
Invoke controller middleware for ThinkJS 3.x
https://github.com/thinkjs/think-controller
controller middleware think-middleware
Last synced: 4 days ago
JSON representation
Invoke controller middleware for ThinkJS 3.x
- Host: GitHub
- URL: https://github.com/thinkjs/think-controller
- Owner: thinkjs
- License: mit
- Created: 2017-03-29T03:37:08.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-07-01T15:19:34.000Z (over 3 years ago)
- Last Synced: 2024-10-03T09:36:25.574Z (about 1 month ago)
- Topics: controller, middleware, think-middleware
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 5
- Watchers: 12
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- think-awesome - think-controller - johann](https://github.com/toxic-johann) | ![version](https://img.shields.io/npm/v/think-logic.svg) | ![](https://travis-ci.org/thinkjs/think-controller.svg) | ![](https://coveralls.io/repos/github/thinkjs/think-controller/badge.svg) | Invoke controller action | (Middlewares)
README
# think-controller
[![Build Status](https://img.shields.io/travis/thinkjs/think-controller/master.svg?style=flat-square)](https://travis-ci.org/thinkjs/think-controller)
[![Coverage Status](https://img.shields.io/coveralls/thinkjs/think-controller/master.svg?style=flat-square)](https://coveralls.io/github/thinkjs/think-controller?branch=master)
[![npm](https://img.shields.io/npm/v/think-controller.svg?colorB=brightgreen&style=flat-square)](https://www.npmjs.com/package/think-controller)
[![devDependency Status](https://david-dm.org/thinkjs/think-controller.svg)](https://david-dm.org/thinkjs/think-controller)Invoke controller for ThinkJS 3.x
## How To Use
Modify src/config/middleware.js:
```js
const controller = require('think-controller');module.exports = [
{
handle: controller,
options: {
emptyModule: '',
emptyController: '',
preSetStatus: 200
}
}
];
```## Options
* `emptyModule` {String} default module when not found
* `emptyController` {String} default controller when not found
* `preSetStatus` {Number} preset http status when action exist
Koa set http status to 404 before request handling, and will changed when set body or status properties. when `preSetStatus` is set and action exist, it's will preset status before action invoked.