titbit v22.2.1 已经发布,Node.js 环境的 Web 后端框架

栏目: 软件资讯 · 发布时间: 3年前

内容简介:titbit v22.2.1 已经发布,Node.js 环境的 Web 后端框架 此版本更新内容包括: 加载中间件支持传递对象,只要对象包括mid或middleware属性。 要求mid是一个普通函数,运行此函数要返回一个真正的中间件函数。 mi...

titbit v22.2.1 已经发布,Node.js 环境的 Web 后端框架

此版本更新内容包括:

  • 加载中间件支持传递对象,只要对象包括mid或middleware属性。

要求mid是一个普通函数,运行此函数要返回一个真正的中间件函数。

middleware则应该是一个完整的中间件函数,会自动进行this绑定(箭头函数无法绑定this)。

会先检测mid属性,不满足条件才会检测middleware,但是如果mid的返回值不满足条件会抛出错误。


class midt {
  constructor () {
    this.name = 'test-midt'
  }

  mid () {
    let self = this
    return async (c, next) => {
      console.log(self.name)
      await next()
    }
  }

}

class midware {
  constructor () {
    this.name = 'test-midware'
  }

  async middleware (c, next) {
    console.log(this.name)
    await next()
  }

}

const app = new titbit()

app.use( new midt )
  .use(new midware)

app.run(1234)

详情查看:https://gitee.com/daoio/titbit/releases/v22.2.1


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

D3.js in Action

D3.js in Action

Elijah Meeks / Manning Publications / 2014-3 / USD 44.99

Table of Contents Part 1: An Introduction to D3 1 An introduction to D3.js 2 Information Visualization Data Flow 3 D ata-Driven Design and Interaction Part 2: The Pillars of Information......一起来看看 《D3.js in Action》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

MD5 加密
MD5 加密

MD5 加密工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具