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

Producing Masculinity

Producing Masculinity

Michele White / Routledge / 2019-3 / $39.95

Thoughtful, witty, and illuminating, in this book Michele White explores the ways normative masculinity is associated with computers and the Internet and is a commonly enacted online gender practice. ......一起来看看 《Producing Masculinity》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

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

HEX CMYK 互转工具