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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@devrecipies/nestjs-modules

v0.0.8

Published

A collection of NestJS modules for common functionality

Readme

@devrecipies/nestjs-modules

A collection of production-ready NestJS modules for common use cases. This package provides pre-built modules that can be easily integrated into your NestJS applications.

Installation

npm install @devrecipies/nestjs-modules
# or
yarn add @devrecipies/nestjs-modules
# or
pnpm add @devrecipies/nestjs-modules

🔥 Firebase Cloud Messaging (FCM) Module

Send push notifications to mobile devices and web browsers using Firebase Cloud Messaging.

Features

  • ✅ Send notifications to individual devices
  • ✅ Send notifications to multiple devices
  • ✅ Built-in error handling
  • ✅ TypeScript support
  • ✅ Easy configuration

Quick Start

  1. Install Firebase Admin SDK:
npm install firebase-admin
  1. Configure the module:
import { Module } from '@nestjs/common';
import { FcmModule } from '@devrecipies/nestjs-modules';

@Module({
  imports: [
    FcmModule.forRoot({
      config: {
        projectId: process.env.FIREBASE_PROJECT_ID || '',
        clientEmail: process.env.FIREBASE_CLIENT_EMAIL || '',
        privateKey: process.env.FIREBASE_PRIVATE_KEY || '',
      },
    }),
  ],
})
export class AppModule {}
  1. Use the service:
import { Injectable } from '@nestjs/common';
import { FcmService } from '@devrecipies/nestjs-modules';

@Injectable()
export class NotificationService {
  constructor(private readonly fcmService: FcmService) {}

  async sendNotification() {
    const deviceToken = 'user-device-token';
    
    const result = await this.fcmService.sendToDevice(deviceToken, {
      notification: {
        title: 'Hello!',
        body: 'This is a test notification',
      },
      data: {
        customKey: 'customValue',
      },
    });
    
    return result;
  }
}

API Endpoints Example

import { Controller, Post, Body } from '@nestjs/common';
import { FcmService } from '@devrecipies/nestjs-modules';

@Controller()
export class AppController {
  constructor(private readonly fcmService: FcmService) {}

  @Post('send-notification')
  async sendNotification(@Body() dto: { title: string; body: string; token: string }) {
    try {
      const result = await this.fcmService.sendToDevice(dto.token, {
        notification: {
          title: dto.title,
          body: dto.body,
        },
      });

      return { success: true, messageId: result };
    } catch (error) {
      return { success: false, error: error.message };
    }
  }
}

Configuration Options

Environment Variables

FIREBASE_PROJECT_ID=your-project-id
FIREBASE_CLIENT_EMAIL=your-service-account-email
FIREBASE_PRIVATE_KEY=your-private-key

Service Account File

FcmModule.forRoot({
  config: {
    serviceAccountPath: './path/to/serviceAccount.json'
  }
})

Frontend Integration

React + Firebase Setup

  1. Install Firebase SDK:
npm install firebase
  1. Configure Firebase:
import { initializeApp } from 'firebase/app';
import { getMessaging, getToken, onMessage } from 'firebase/messaging';

const firebaseConfig = {
  apiKey: "your-api-key",
  authDomain: "your-project.firebaseapp.com", 
  projectId: "your-project-id",
  storageBucket: "your-project.appspot.com",
  messagingSenderId: "your-messaging-sender-id",
  appId: "your-app-id"
};

const app = initializeApp(firebaseConfig);
const messaging = getMessaging(app);

// Get FCM token
const token = await getToken(messaging, { 
  vapidKey: 'your-vapid-key' 
});

// Listen for messages
onMessage(messaging, (payload) => {
  console.log('Message received:', payload);
});
  1. Test with cURL:
curl -X POST http://localhost:3000/send-notification \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Test Notification",
    "body": "This is a test!",
    "token": "your-device-token"
  }'

API Reference

FcmService Methods

sendToDevice(token: string, message: FcmMessage): Promise<string>

Send a notification to a single device.

sendToMultipleDevices(tokens: string[], message: FcmMessage): Promise<any>

Send a notification to multiple devices.

Message Interface

interface FcmMessage {
  notification?: {
    title?: string;
    body?: string;
    icon?: string;
  };
  data?: { [key: string]: string };
  android?: AndroidConfig;
  ios?: IosConfig;
  webpush?: WebpushConfig;
}

Examples

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Support

For issues and questions, please visit our GitHub repository.