Compare commits

..

No commits in common. "master" and "v2" have entirely different histories.
master ... v2

3 changed files with 6 additions and 8 deletions

View File

@ -1,14 +1,12 @@
![downloads](https://img.shields.io/npm/dt/@gm5/controller.svg)
![version](https://img.shields.io/npm/v/@gm5/controller.svg)
![module info](https://nodei.co/npm/@gm5/controller.png?downloads=true&downloadRank=true&stars=true)
# @gm5/controller
> 控制器基类。
## 安装
> 一般不需要单独安装, 该模块包含在`@gm5/core`的依赖里。
```bash
npm i @gm5/controller
npm install @gm5/controller
```

View File

@ -30,10 +30,10 @@ export default class Controller {
let { __mix_key__ } = this.request
return this.context.$$jwt.sign(data, __mix_key__)
},
verify: token => {
verify: () => {
this.#auth = null
let token = this.request.header('authorization')
let { __mix_key__ } = this.request
token ??= this.request.header('authorization')
if (token) {
this.#auth = this.context.$$jwt.verify(token, __mix_key__)
@ -94,7 +94,7 @@ export default class Controller {
this.response.cookie(key, val, opt)
}
// 会话读写, 返回的是Promise对象
// 会话读写
session(key, val) {
let { ssid } = this.request
if (this.context.$$session) {

View File

@ -1,6 +1,6 @@
{
"name": "@gm5/controller",
"version": "2.0.3",
"version": "2.0.0",
"type": "module",
"description": "控制器基类。",
"main": "index.js",