npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nestjs-mod/fastify

v1.8.3

Published

Application modules with Fastify adapter for NestJS-mod

Downloads

127

Readme

@nestjs-mod/fastify

Application modules with Fastify adapter for NestJS-mod

NPM version monthly downloads Telegram Discord

Installation

npm i --save fastify @nestjs/platform-fastify @nestjs-mod/fastify

Modules

| Link | Category | Description | | ---- | -------- | ----------- | | FastifyNestApplicationInitializer | system | Fastify NestJS application initializer. | | FastifyNestApplicationListener | system | Fastify NestJS application listener. |

Modules descriptions

FastifyNestApplicationInitializer

Fastify NestJS application initializer.

Use in NestJS-mod

Use without options.

import { bootstrapNestApplication } from '@nestjs-mod/common';
import { FastifyNestApplicationInitializer } from '@nestjs-mod/fastify';

bootstrapNestApplication({
  modules: {
    system: [FastifyNestApplicationInitializer.forRoot()],
  },
});

Example of register fastify plugin.

import { bootstrapNestApplication } from '@nestjs-mod/common';
import { FastifyNestApplicationInitializer } from '@nestjs-mod/fastify';
import * as fmp from 'fastify-multipart';

bootstrapNestApplication({
  modules: {
    system: [
      FastifyNestApplicationInitializer.forRoot({
        staticConfiguration: {
          wrapFastifyAdapter: (fastifyAdapter: FastifyAdapter) => {
            fastifyAdapter.register(fmp);
          },
        },
      }),
    ],
  },
});

Static configuration

| Key | Description | Constraints | Default | Value | | ------ | ----------- | ----------- | ------- | ----- | |cors|CORS options from CORS package|optional|-|-| |bodyParser|Whether to use underlying platform body parser.|optional|-|-| |httpsOptions|Set of configurable HTTPS options|optional|-|-| |rawBody|Whether to register the raw request body on the request. Use req.rawBody.|optional|-|-| |defaultLogger|Fastify logger for application|optional|-|-| |logger|Specifies the logger to use. Pass false to turn off logging.|optional|-|-| |abortOnError|Whether to abort the process on Error. By default, the process is exited. Pass false to override the default behavior. If false is passed, Nest will not exit the application and instead will rethrow the exception. @default true|optional|-|-| |bufferLogs|If enabled, logs will be buffered until the "Logger#flush" method is called. @default false|optional|-|-| |autoFlushLogs|If enabled, logs will be automatically flushed and buffer detached when application initialization process either completes or fails. @default true|optional|-|-| |preview|Whether to run application in the preview mode. In the preview mode, providers/controllers are not instantiated & resolved. @default false|optional|-|-| |snapshot|Whether to generate a serialized graph snapshot. @default false|optional|-|-| |forceCloseConnections|Force close open HTTP connections. Useful if restarting your application hangs due to keep-alive connections in the HTTP adapter.|optional|true|-| |wrapFastifyAdapter|Method for additional actions before listening|optional|-|-|

Back to Top


FastifyNestApplicationListener

Fastify NestJS application listener.

Use in NestJS-mod

Use with manual environments and custom configuration.

import { bootstrapNestApplication, isInfrastructureMode } from '@nestjs-mod/common';
import { FastifyNestApplicationInitializer, FastifyNestApplicationListener } from '@nestjs-mod/fastify';
import { Logger } from '@nestjs/common';

bootstrapNestApplication({
  modules: {
    system: [
      FastifyNestApplicationInitializer.forRoot(),
      FastifyNestApplicationListener.forRoot({
        staticEnvironments: { port: 3000 },
        staticConfiguration: {
          mode: isInfrastructureMode() ? 'silent' : 'listen',
          preListen: async ({ app }) => {
            if (app) {
              app.setGlobalPrefix('api');
            }
          },
          postListen: async ({ current }) => {
            Logger.log(
              `🚀 Application is running on: http://${current.staticEnvironments?.hostname || 'localhost'}:${
                current.staticEnvironments?.port
              }/api`
            );
          },
        },
      }),
    ],
  },
});

Static environments

| Key | Description | Sources | Constraints | Default | Value | | ------ | ----------- | ------- | ----------- | ------- | ----- | |port|The port on which to run the server.|obj['port'], process.env['PORT']|optional|3000|3000| |hostname|Hostname on which to listen for incoming packets.|obj['hostname'], process.env['HOSTNAME']|optional|0.0.0.0|0.0.0.0|

Static configuration

| Key | Description | Constraints | Default | Value | | ------ | ----------- | ----------- | ------- | ----- | |mode|Mode of start application: init - for run NestJS life cycle, listen - for full start NestJS application|optional|listen|-| |preListen|Method for additional actions before listening|optional|-|-| |postListen|Method for additional actions after listening|optional|-|-| |defaultLogger|Fastify logger for application|optional|-|-| |enableShutdownHooks|Enable shutdown hooks|optional|true|-| |globalPrefix|Global prefix|optional|api|-| |autoCloseTimeoutInInfrastructureMode|Timeout seconds for automatically closes the application in infrastructure mode if the application does not close itself (zero - disable)|optional|-|-| |logApplicationStart|Log application start|optional|true|-|

Back to Top

Links

  • https://github.com/nestjs-mod/nestjs-mod - A collection of utilities for unifying NestJS applications and modules
  • https://github.com/nestjs-mod/nestjs-mod-contrib - Contrib repository for the NestJS-mod
  • https://github.com/nestjs-mod/nestjs-mod-example - Example application built with @nestjs-mod/schematics
  • https://github.com/nestjs-mod/nestjs-mod/blob/master/apps/example-basic/INFRASTRUCTURE.MD - A simple example of infrastructure documentation.
  • https://github.com/nestjs-mod/nestjs-mod-contrib/blob/master/apps/example-prisma/INFRASTRUCTURE.MD - An extended example of infrastructure documentation with a docker-compose file and a data base.
  • https://dev.to/endykaufman/collection-of-nestjs-mod-utilities-for-unifying-applications-and-modules-on-nestjs-5256 - Article about the project NestJS-mod
  • https://habr.com/ru/articles/788916 - Коллекция утилит NestJS-mod для унификации приложений и модулей на NestJS

License

MIT