I am trying to use cloud functions to do a pub sub cloud scheduled function in nodjs but I am having difficulty calling the function because every time I compile the code I get this error
Error: Failed to load function definition from source: Failed to generate manifest from function source: ReferenceError: Cannot access 'sendNotifications' before initialization
what is the correct way I am meant to add the send notification function into my pub sub scheduler
// The Cloud Functions for Firebase SDK to create Cloud Functions and set up triggers.
const functions = require('firebase-functions');
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const cors = require('cors');
const errorHandler = require('./_middleware/error-handler');
// The Firebase Admin SDK to access Firestore.
const admin = require('firebase-admin');
admin.initializeApp();
const sendNotifications = require('./notifications.controller')
// Create an Express object and routes (in order)
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cookieParser());
// allow cors requests from any origin
app.use(cors());
// api routes
app.use('/', require('./invites.controller'));
app.use('/', require('.//payments.controller'));
// INVITE PAGE
app.get('/invite/:inviteId', function(request, response) {
response.sendFile(__dirname + '/download.html');
});
// global error handler
app.use(errorHandler);
// Set our GCF handler to our Express app.
exports.invites = functions.region('europe-west2').https.onRequest(app);
exports.payments = functions.region('europe-west2').https.onRequest(app);
exports.notificationScheduler = functions.pubsub
.schedule('0 8 * * *')
.timeZone('Europe/London')
.onRun(async() => {
await sendNotifications()
});