Skip to content
This repository was archived by the owner on Jul 8, 2023. It is now read-only.
This repository was archived by the owner on Jul 8, 2023. It is now read-only.

Unify the way of importing and initializing the app and other pieces #259

@ivansieder

Description

@ivansieder

🚀 Feature Proposal

I'd suggest three minor things to enhance the docs:

  • unify the way of importing and initializing the app throughout the docs so that they're the same across the whole docs
  • as discussed with Matteo, it might make sense to rename references to fastify/server to app throughout the docs.
  • for the basic examples, I'd suggest to keep all the examples with the same configuration (which is to enable the logger)
  • name name the parameters in the docs consistently (sometimes it's req and sometimes it's request)

Motivation

Currently, there are different examples on how Fastify is being imported and how the app is being initialized (see below). Also, with the rise of ESM-Modules, imports mostly shift from something like const Fastify = require('fastify') to import Fastify from 'fastify', which makes things, such as const app = require('fastify')({ logger: true }) impossible. Also, it's less of a mind-shifting to use the same terms for the same thing (using the term app instead of using fastify or server for actually the same thing)

Currently, these are the two variations:
JavaScript (shortened):

const fastify = require('fastify')({
  logger: true
})

TypeScript (shortened):

import Fastify from 'fastify'
const server = Fastify({})

Example

With this proposal, the above examples and all examples throughout the documentation would be unified in terms of how to name and initialize the app. Also, the example of directly importing and initializing the app in one step will be split up into an import and a separate initialization. This avoids varying terms like fastify and server for actually the same thing.

JavaScript (shortened):

const Fastify = require('fastify')
const app = Fastify({ logger: true })

TypeScript (shortened):

import Fastify from 'fastify'
const app = Fastify({ logger: true })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions