Home / File/ http2.js — fastify Source File

http2.js — fastify Source File

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

Entity Profile

Source Code

'use strict'

const fs = require('node:fs')
const path = require('node:path')
const fastify = require('../fastify')({
  http2: true,
  https: {
    key: fs.readFileSync(path.join(__dirname, '../test/https/fastify.key')),
    cert: fs.readFileSync(path.join(__dirname, '../test/https/fastify.cert'))
  },
  logger: true
})

const opts = {
  schema: {
    response: {
      '2xx': {
        type: 'object',
        properties: {
          hello: {
            type: 'string'
          }
        }
      }
    }
  }
}

fastify
  .get('/', opts, function (req, reply) {
    reply.header('Content-Type', 'application/json').code(200)
    reply.send({ hello: 'world' })
  })

fastify.listen({ port: 3000 }, err => {
  if (err) {
    throw err
  }
})

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free