I have created firebase cloud functions using typescript and express. When i write routing in index.ts(working code)and deployed on cloud it's working. When I use express.Route() and then try to deploy functions it is giving error.
Working: index.js -
const app = express();
import * as enquiryService from './modules/enquiry/enquiry.service';
app.post('/enquiry/subscriber', enquiryService.saveSubscriber);
app.post('/enquiry/contact-us', enquiryService.saveContactUs);
export const api = functions.region('asia-northeast1').https.onRequest(app);
Below is index js modified code using express.Route() but not working. while deploying using "firebase deploy --only functions" it is giving me an error: "functions[api(asia-northeast1)]: Deployment error. Function failed on loading user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs"
const app = express();
app.use(cors({ origin: '*' }));
import { enquiryRouter } from './modules/enquiry/enquiry.routes'
app.use("/enquiry", enquiryRouter);
export const api = functions.region('asia-northeast1').https.onRequest(app);
Here enquiryRoutes is declared in enquiry.routes.ts
import express from 'express';
export const enquiryRouter = express.Router();