Reputation: 287
Hi I'm writing a Cloud Function for Firebase. Everything worked great but now I'm trying to deploy a new function createRequestDoc
The code of the function is like this:
import * as functions from "firebase-functions";
import { admin } from "../config/firebase";
const createRequestRealTimeDoc = functions
.region("europe-west3")
.firestore.document("/bank_requests/{documentId}")
.onCreate(async (snap, context) => {
console.info("here");
const db = admin.database();
const ref = db.ref("server/fireblog");
// grap the content of the new request
const request = snap.data();
const requestRef = ref.child("requests");
const newRequestRef = requestRef.push();
return newRequestRef.set({ ...request });
});
export default createRequestRealTimeDoc
But when I'm trying to export the function nothing happend the previous functions are deployed but not that one and I get no error message
Here are my index.ts with all my export
import * as functions from "firebase-functions";
import createOperation from "./createOperation/createOperation";
import handleRequestUpdate from "./handleRequestUpdate/handleRequestUpdate";
import createRequestRealTimeDoc
from "./createRequestRealTimeDoc/createRequestRealTimeDoc";
import app from "./api/server";
exports.createOperation = createOperation;
exports.handleRequestUpdate = handleRequestUpdate;
exports.createRequestDoc = createRequestRealTimeDoc;
exports.app = functions.region("europe-west3").https.onRequest(app);
Upvotes: 3
Views: 913
Reputation: 2094
If you are using Typescript and you also have a client app in the same repo, you might made the same mistake as I did:
If you accidentally import something from the frontend client folder, the the Typescript will compile the new files differently, to include the client folder in the function lib folder.
So to fix that you'll need to remove the import from client folder.
Upvotes: 1
Reputation: 287
I fix this problem by deleting the old lib foler when ts compile and now it works perfectly
Upvotes: 4