Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
yutent | 7fbf720e62 | |
yutent | 655c5e34fa | |
yutent | 52b8e3553e |
|
@ -1,12 +1,14 @@
|
|||
![module info](https://nodei.co/npm/@gm5/controller.png?downloads=true&downloadRank=true&stars=true)
|
||||
![downloads](https://img.shields.io/npm/dt/@gm5/controller.svg)
|
||||
![version](https://img.shields.io/npm/v/@gm5/controller.svg)
|
||||
|
||||
# @gm5/controller
|
||||
|
||||
> 控制器基类。
|
||||
|
||||
## 安装
|
||||
> 一般不需要单独安装, 该模块包含在`@gm5/core`的依赖里。
|
||||
|
||||
```bash
|
||||
npm install @gm5/controller
|
||||
npm i @gm5/controller
|
||||
```
|
||||
|
||||
|
|
6
index.js
6
index.js
|
@ -30,10 +30,10 @@ export default class Controller {
|
|||
let { __mix_key__ } = this.request
|
||||
return this.context.$$jwt.sign(data, __mix_key__)
|
||||
},
|
||||
verify: () => {
|
||||
verify: token => {
|
||||
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) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@gm5/controller",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.3",
|
||||
"type": "module",
|
||||
"description": "控制器基类。",
|
||||
"main": "index.js",
|
||||
|
|
Loading…
Reference in New Issue