Q:

Problem with messaging() in node.js for firebase

I want to organize sending push- notifications on adding a document to firestore. I am using the code from examples from firebase site for node.js.
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
var message = {
    notification: {
        title: 'title!',
        body: 'body'
    },
    topic: "all"
};

exports.createRequest = functions.firestore
    .document('Requests/{RequestsId}')
    .onCreate((snap, context) => {
        console.log('We have a new request');
        // Send a message to devices subscribed to the provided topic.
        admin.messaging().send(message)
            .then((response) => {
                console.log('Successfully sent message:', response);
            }).catch((error) => {
                console.log('Error sending message:', error);
            });
        return 0;
    });

When I try to deploy I am getting an error: 

Each then() should return a value or throw  promise/always-return" for string .then((response) => {

A:

Change this:
admin.messaging().send(message)
.then((response) => {
  console.log('Successfully sent message:', response);
}).catch((error) => {
  console.log('Error sending message:', error);
  });
 return 0;
 });

Into this:
return admin.messaging().send(message)
.then((response) => {
 console.log('Successfully sent message:', response);
 return null;
}).catch((error) => {
 console.log('Error sending message:', error);
  });
});

You need to terminate functions correctly, so you can avoid excessive charges from functions that run for too long or loop infinitely.
You can use the following ways to terminate your function:

Resolve functions that perform asynchronous processing (also known as "background functions") by returning a JavaScript promise.
Terminate HTTP functions with res.redirect(), res.send(), or res.end().
Terminate a synchronous function with a return; statement.

