I have this code:
import { defineString } from 'firebase-functions/params'
import { onMessagePublished } from 'firebase-functions/v2/pubsub'
import { firestore } from '~/providers'
const topic = defineString('TRANSCODER_TOPIC')
export const onTranscoder = onMessagePublished(topic.value(), async (event) => {
const {
job: { name, state },
} = event.data.message.json
const queryRef = firestore.collection('videos').where('transcoder.job', '==', name).limit(1)
const snapshot = await queryRef.get()
const ready = state === 'SUCCEEDED'
await firestore.collection('videos').doc(snapshot.docs[0].id).set({ transcoder: { ready } }, { merge: true })
})
When I deploy it, I get several errors, which, not surprisingly, do not tell me the specific line causing the issue—typical of Google’s error messages.
If I follow the suggestion and change the code to:
export const onTranscoder = onMessagePublished(topic, async (event) => {
I get an error because onMessagePublished requires a string.
Am I going crazy? How can I resolve this?
Google is forcing everyone to migrate to Firebase Functions V2 but fails to provide complete migration documentation, missing APIs, etc.