百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

firestore-cloud-functions-typescript

> DevOps
开源

在 TypeScript 中使用 Firestore 的 Firebase 云函数。以社交网络为例

188 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

在 TypeScript 中使用 Firestore 的 Firebase 云函数。以社交网络为例

Cloud Functions for Firebase: Typescript with Firebase Firestore

This is an example Firebase project for using TypeScript with Cloud Functions for Firebase and Firestore

Before start

This cloud functions represent one of my last works with cloud functions: Implement a basic social media representation with posts, followers and feed, together with likes and comments. What will our cloud functions control?

  • Update the feed of the users when they follow/un-follow another user
  • Send notifications and update the Events data for an user when one of their posts receive a like or comment.
  • Send notifications when we have a new follower
  • In Progress : Update all the denormalized data from the user when he change his profile(username or profile picture)

I'm not an expert in noSQL data models or Typescript, but I have been working with Firebase approximately for the last two years. For that reason, feel free to suggest changes or just send a pull request. You can find an example of the database structure in the project.

At the moment there is not to much information or example about work with Typescript and Firestore. If you want to learn more I suggest you to visit the profile of Thomas Bouldin, aka Inlined who did a great talk in #FirebaseSummit about write quality cloud functions with Typescript. Also don't forget to give a look to the Firebase Functions samples.

Why Firestore?

Cloud Firestore is a cloud-hosted, NoSQL database that your iOS, Android, and web apps can access directly via native SDKs. Cloud Firestore is also available in native Node.js, Java, Python, and Go SDKs, in addition to REST and RPC APIs.

Following Cloud Firestore's NoSQL data model, you store data in documents that contain fields mapping to values. These documents are stored in collections, which are containers for your documents that you can use to organize your data and build queries.

Additionally, querying in Cloud Firestore is expressive, efficient, and flexible. Create shallow queries to retrieve data at the document level without needing to retrieve the entire collection, or any nested subcollections. Add sorting, filtering, and limits to your queries or cursors to paginate your results. To keep data in your apps current, without retrieving your entire database each time an update happens, add realtime listeners. Adding realtime listeners to your app notifies you with a data snapshot whenever the data your client apps are listening to changes, retrieving only the new changes.

Why TypeScript?

TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.

One of the biggest challenges with developing in JavaScript is that it is very easy to write code that has runtime errors. TypeScript enables the fast development of JavaScript with optional types. When types are used, supported editors provide auto-suggest for methods and properties along with syntax highlighting of errors, which speeds development.

TypeScript supports targeting different browsers, and optimizes the resulting JavaScript. It is much easier to write clean, consistent code across a project and development team. TypeScript offers support for the latest and evolving JavaScript features like async functions and decorators, to help build robust components.

For a nice intro to TypeScript, check out the TypeScript PlayGround.

Instructions

Prerequisites

  1. The latest copy of the firebase-tools.
  2. The latest version of firebase-admin and firebase-functions

Setup

  1. Clone this repo.
  2. Set firebase-tools to use your project with firebase use
  3. Move inside your functions\ folder
  4. Update your dependencies with npm install
  5. Deploy your functions with npm run deploy

Note: with TypeScript you need to build the JavaScript files before deploying, so there's an npm script that does the steps. You can see that and a few other handy shortcuts in package.json

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptcloud-function-for-firebasecloud-functionsfirebasefirebase-cloud-messaging

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类DevOps
定价开源

> 相关工具

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理