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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@stevenkellner/firebase-function

v1.4.141

Published

A TypeScript library designed to simplify the creation and deployment of Firebase functions. It provides a structured and type-safe way to define Firebase functions, requests, and schedules.

Readme

Firebase Function

Overview

A TypeScript library designed to simplify the creation and deployment of Firebase functions. It provides a structured and type-safe way to define Firebase functions, requests, and schedules.

Table of Contents

Features

  • TypeScript Support: Leverage the power of TypeScript for type safety and better development experience.
  • Firebase Functions: Easily create and manage Firebase functions.
  • Firebase Requests: Define and handle Firebase HTTPS requests.
  • Firebase Schedules: Schedule and manage Firebase scheduled functions.

Installation

To install the package, use npm:

npm install @stevenkellner/firebase-function

Usage

Creating Firease Function / Request / Schedule

To create a Firebase function, request, or schedule, use the respective builder methods provided by the library. Here is an example:

import { FirebaseFunction, FirebaseRequest, FirebaseSchedule } from '@stevenkellner/firebase-function/admin';
import type { ITypeBuilder } from '@stevenkellner/typescript-common-functionality';

export class MyFirebaseFunction extends FirebaseFunction<MyParameters, MyReturnType> {

    public parametersBuilder: ITypeBuilder<Flatten<MyParameters>, MyParameters> = // Type builder to build parameters

    public constructor(userId: string | null) {
        super();
    }

    public async execute(parameters: MyParameters): Promise<MyReturnType> {
        // Function execution logic here
    }
}

export class MyFirebaseRequest extends FirebaseRequest<MyParameters, MyReturnType> {

    public parametersBuilder: ITypeBuilder<Flatten<MyParameters>, MyParameters> = // Type builder to build parameters

    public constructor() {
        super();
    }

    public async execute(parameters: MyParameters): Promise<MyReturnType> {
        // Request execution logic here
    }
}

export class MyFirebaseSchedule extends FirebaseSchedule {

    public constructor() {
        super();
    }

    public async execute(): Promise<void> {
        // Schedule execution login here
    }
}

Creating Firebase Functions Strukture

To create Firebase functions, use the createFirebaseFunctions method:

import { createFirebaseFunctions } from '@stevenkellner/firebase-function/admin';

const firebaseFunctions = createFirebaseFunctions(builder => ({
    function: builder.function(MyFirebaseFunction),
    requests: {
        request: builder.request(MyFirebaseRequest)
    },
    schedule: builder.schedule(MyFirebaseSchedule, "0 0 1 1 *", "europe/berlin")
}));

Providing Firebase Functions

To provide Firebase functions, use the provideFirebaseFunctions method:

import { provideFirebaseFunctions } from '@stevenkellner/firebase-function/admin';

const macKey = // My private message authenication key
const regions = ['europe-west1'];

const runnableFunctions = provideFirebaseFunctions(firebaseFunctions, macKey, regions);

Call Function on Client

To call a Firebase function on the client side, use the httpsCallable method from the Firebase SDK. Here is an example:

import type { ITypeBuilder } from '@stevenkellner/typescript-common-functionality';
import { createFirebaseFunctions, IFirebaseFunction, IFirebaseRequest } from '../../client';
import { initializeApp } from 'firebase/app';
import { getFunctions } from 'firebase/functions';

export class MyFirebaseFunction extends IFirebaseFunction<MyParameters, MyReturnType> {

    public readonly returnTypeBuilder: ITypeBuilder<Flatten<MyReturnType>, MyReturnType> = // Type builder to build return type
}

export class MyFirebaseRequest extends IFirebaseRequest<MyParameters, MyReturnType> {

    public readonly returnTypeBuilder: ITypeBuilder<Flatten<MyReturnType>, MyReturnType> = // Type builder to build return type
}

initializeApp({
    apiKey: // Your FIREBASE_API_KEY,
    authDomain: // Your FIREBASE_AUTH_DOMAIN,
    databaseURL: // Your FIREBASE_DATABASE_URL,
    projectId: // Your FIREBASE_PROJECT_ID,
    storageBucket: // Your FIREBASE_STORAGE_BUCKET,
    messagingSenderId: // Your FIREBASE_MESSAGING_SENDER_ID,
    appId: // Your FIREBASE_APP_ID
});
const functions = getFunctions(undefined, 'europe-west1');

const macKey = // My private message authenication key
const firebaseFunctions = createFirebaseFunctions(/* Your base url to firebase functions */, 'europe-west1', macKey, builder => ({
    function: builder.function(MyFirebaseFunction),
    requests: {
        request: builder.request(MyFirebaseRequest)
    }
}));

Testing

To run tests, use the following command:

npm run test

To generate a coverage report, use:

npm run test:coverage

and view it with

npm run coverage:report

Continuous Integration

Build, Test and Lint

Build, test and lint Node.js Package

On each push and pull request, the CI runs the build, test and lint script to verify the package.

Coverage Report

Run Test with Coverage Report and upload it to Github Pages

The coverage report is generated automatically by the CI on each push and pull request. You can view the latest coverage report here.

Publish to npm

Publish Node.js Package

The library is published automatically as a npm package and a github release is created by the CI on each new release tag. The npm package can be found here, you can install it with npm install @stevenkellner/firebase-function.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.