Skip to content

Expose the Fastify options type  #591

@meotimdihia

Description

@meotimdihia

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

Currently, we have to write type for AppOptions, while it is Fastify options. And why we can't improve by importing the Fastify options type? It should be easier to code if we can do it. For example, I don't know what is logger type looks like.

https://github.com/fastify/fastify-cli/blob/master/templates/app-ts/src/app.ts#L5

export type AppOptions = {
  // Place your custom options for app below here.
  logger: <???>
  trustProxy: true,
  maxParamLength: number,
  connectionTimeout: number,
  requestTimeout: number,
  bodyLimit: number,
  exposeHeadRoutes: boolean,
  rewriteUrl: (req: FastifyRequest) => any, // I have to use <any> for this ...
  ajv: {
    customOptions: {
      removeAdditional: boolean,
      useDefaults: boolean,
      coerceTypes: string
      allErrors: boolean,
      allowUnionTypes: boolean,
    },
    plugins: any[]
  } 
} & Partial<AutoloadPluginOptions>;

Motivation

Improve the plugin. Take advantage of Typescript type.

Example

export type AppOptions = FastifyOptions & Partial<AutoloadPluginOptions>;

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