Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
Cannot access function in express for pub sub cloud function

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()
  });
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!