Home / File/ webstream.js — fastify Source File

webstream.js — fastify Source File

Architecture documentation for webstream.js, a javascript file in the fastify codebase.

Entity Profile

Source Code

'use strict'

const fastify = require('../../fastify')({
  logger: false
})

const payload = JSON.stringify({ hello: 'world' })

fastify.get('/', function (req, reply) {
  const stream = new ReadableStream({
    start (controller) {
      controller.enqueue(payload)
      controller.close()
    }
  })
  return new Response(stream, {
    status: 200,
    headers: {
      'content-type': 'application/json; charset=utf-8'
    }
  })
})

fastify.listen({ port: 3000 }, (err, address) => {
  if (err) throw err
  console.log(`Server listening on ${address}`)
})

Frequently Asked Questions

What does webstream.js do?
webstream.js is a source file in the fastify codebase, written in javascript.
Where is webstream.js in the architecture?
webstream.js is located at examples/benchmark/webstream.js (directory: examples/benchmark).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free