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

Data Structures and Algorithms in Java

Data Structures and Algorithms in Java

Robert Lafore / Sams / 2002-11-06 / USD 64.99

Data Structures and Algorithms in Java, Second Edition is designed to be easy to read and understand although the topic itself is complicated. Algorithms are the procedures that software programs use......一起来看看 《Data Structures and Algorithms in Java》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

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

RGB CMYK 互转工具

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

HEX CMYK 互转工具