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://codercto.com/soft/d/2084.html

Algorithms and Theory of Computation Handbook

Algorithms and Theory of Computation Handbook

Mikhail J. Atallah (Editor) / CRC-Press / 1998-09-30 / USD 94.95

Book Description This comprehensive compendium of algorithms and data structures covers many theoretical issues from a practical perspective. Chapters include information on finite precision issues......一起来看看 《Algorithms and Theory of Computation Handbook》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

在线进制转换器
在线进制转换器

各进制数互转换器

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

多种字符组合密码