Node.js 的 Web 框架 Fastify

码农软件 · 软件分类 · Web框架 · 2019-03-24 22:12:54

软件介绍

Fastify 是一个高度专注于以最少开销和强大的插件架构为开发者提供最佳体验的 Web 框架。 它受到了 Hapi 和 Express 的启发。

安装

npm i fastify --save

示例代码

// Require the framework and instantiate it
const fastify = require('fastify')()

// Declare a route
fastify.get('/', function (request, reply) {
  reply.send({ hello: 'world' })
})

// Run the server!
fastify.listen(3000, function (err) {
  if (err) throw err
  console.log(`server listening on ${fastify.server.address().port}`)
})

核心特性:

  • 100% 异步:框架的核心都是用异步代码实现的

  • 高性能:每秒可以提供34000个请求

  • 可扩展:Fastify 通过其钩子,插件和装饰器完全可扩展

  • 基于模式:即使不是强制性的,我们建议使用 JSON Schema 来验证路由并序列化输出

  • 日志记录:日志非常重要,但成本高昂;我们选择了最好的记录器 Pino

  • 对开发者友好:该框架构建非常有表现力,不会牺牲性能和安全性

本文地址:https://www.codercto.com/soft/d/2084.html

The Linux Command Line

The Linux Command Line

William E. Shotts Jr. / No Starch Press, Incorporated / 2012-1-17 / USD 39.95

You've experienced the shiny, point-and-click surface of your Linux computer-now dive below and explore its depths with the power of the command line. The Linux Command Line takes you from your very ......一起来看看 《The Linux Command Line》 这本书的介绍吧!

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

多种字符组合密码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码