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

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

内容简介: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


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

查看所有标签

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

Introduction to Semi-Supervised Learning

Introduction to Semi-Supervised Learning

Xiaojin Zhu、Andrew B. Goldberg / Morgan and Claypool Publishers / 2009-6-29 / USD 40.00

Semi-supervised learning is a learning paradigm concerned with the study of how computers and natural systems such as humans learn in the presence of both labeled and unlabeled data. Traditionally, le......一起来看看 《Introduction to Semi-Supervised Learning》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

html转js在线工具
html转js在线工具

html转js在线工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具