
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
@firebase/functions-types
Advanced tools
@firebase/functions-types is a TypeScript type definition package for Firebase Cloud Functions. It provides type definitions for interacting with Firebase Cloud Functions, enabling developers to write type-safe code when working with Firebase's serverless functions.
Callable Functions
This feature allows you to define and call HTTPS callable functions from your client app. The code sample demonstrates how to call a function named 'addMessage' and handle the response.
import { HttpsCallable } from '@firebase/functions-types';
const addMessage: HttpsCallable = functions.httpsCallable('addMessage');
addMessage({ text: 'Hello, World!' })
.then(result => {
console.log(result.data);
})
.catch(error => {
console.error('Error:', error);
});
Background Functions
This feature allows you to define background functions that trigger on specific events, such as user creation. The code sample shows how to create a function that triggers when a new user is created.
import { EventContext } from '@firebase/functions-types';
export const onUserCreate = functions.auth.user().onCreate((user, context: EventContext) => {
console.log('New user created:', user.uid);
});
HTTP Functions
This feature allows you to define HTTP functions that respond to HTTP requests. The code sample demonstrates how to create a simple HTTP function that responds with 'Hello, World!'.
import { Request, Response } from '@firebase/functions-types';
export const helloWorld = functions.https.onRequest((req: Request, res: Response) => {
res.send('Hello, World!');
});
The firebase-functions package provides the actual implementation for Firebase Cloud Functions, including the ability to define and deploy functions. It is more comprehensive and includes runtime code, whereas @firebase/functions-types focuses solely on type definitions.
The aws-lambda package provides type definitions for AWS Lambda functions. It is similar in that it offers type safety for serverless functions, but it is specific to AWS Lambda rather than Firebase Cloud Functions.
The azure-functions package provides type definitions for Azure Functions. Like @firebase/functions-types, it offers type safety for serverless functions, but it is tailored for Microsoft's Azure platform.
This package is not intended for direct usage, and should only be used via the officially supported firebase package.
FAQs
@firebase/functions Types
The npm package @firebase/functions-types receives a total of 2,755,448 weekly downloads. As such, @firebase/functions-types popularity was classified as popular.
We found that @firebase/functions-types demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.