Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cloud functions to 2nd generation #301

Merged
merged 16 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ Output will be in `src\android\app\build\outputs\apk\prod\release`

## Trouble shooting

- run `npx react-native clean`

### Android trouble

Try
Expand All @@ -92,11 +94,12 @@ or try `npx react-native run-android --mode=prodDebug`

Try

- `bundle install` This command installs all the required Ruby gems specified in the project's Gemfile. It ensures that your development environment has the necessary dependencies to run the project successfully. BUT first is good to run `gem update bundler` to ensure that your Bundler is up to date.
- `bundle install` This command installs all the required Ruby gems specified in the project's Gemfile. It ensures that your development environment has the necessary dependencies to run the project successfully. BUT first is good to run `gem update bundler`/ or `sudo gem update bundler` to ensure that your Bundler is up to date.
- sometimes help with `gem update --system`
- if it stay "Successfully launched the app on the simulator" but after that it's like it don't have connection to the simulator anymore, then probably it run Release mode. You can open Xcode Check in `Product -> Scheme -> Edit Scheme -> change to Debug mode`.
- sometimes it helps to open Xcode and build by pressing Command+B
- often it helps to clean pod `rm -rf Pods rm -rf Podfile.lock pod install`
- can help to clean cach `pod cache clean --all`

# We who have worked with the project

Expand Down
13 changes: 13 additions & 0 deletions functions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## 2nd gen cloud function

## onCall

onCall, you need to path the whole url and not just a name of the function
here is more info https://github.com/invertase/react-native-firebase/issues/6622#issuecomment-1287460800

## onSchedule

Most of second gen functions is at europe-north1.
But onSchrdul function doesn't support all region https://github.com/firebase/firebase-functions/issues/1293#issuecomment-1297524616
In summer 2024 I tried europe-north1, europe-west1, europe-west2 it didn't work, so I deployed it to default us-central1. But maybe in future they will fix it.
So when you deploy onSchedul function, just comment awaty setGlobalOptions({ region: "europe-north1" }); at config file
19 changes: 14 additions & 5 deletions functions/config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
const functions = require("firebase-functions");
const { cert } = require("firebase-admin/app");
const { setGlobalOptions } = require("firebase-functions/v2");
const dotenv = require("dotenv");

const SERVICE_ACCOUNT_FILE_PATH = functions.config().service_acc.file_path;
const STORAGE_BUCKET = functions.config().storage.bucket;
// Load environment variables from .env file
dotenv.config();

const serviceAccount = require(SERVICE_ACCOUNT_FILE_PATH);
//locate all functions closest to users
setGlobalOptions({ region: "europe-north1" });

// Define parameters
const serviceAccountFilePath = process.env.SERVICE_ACCOUNT_FILE_PATH;
const storageBucket = process.env.STORAGE_BUCKET;

// Initialize Firebase Admin SDK
const serviceAccount = require(serviceAccountFilePath);

exports.firebaseConfig = {
credential: cert(serviceAccount),
storageBucket: STORAGE_BUCKET,
storageBucket: storageBucket,
};
51 changes: 27 additions & 24 deletions functions/index.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
const admin = require("firebase-admin");

const { createUser } = require("./src/createUser");
const { deleteUser } = require("./src/deleteUser");
const { updateMonth } = require("./src/updateMonth");
const { updateYear } = require("./src/updateYear");
const { assignAdminClaim } = require("./src/assignAdminClaim");
const { initializeApp } = require("firebase-admin/app");
const { createUserSecondGen } = require("./src/createUserSecondGen");
const { updateYearSecondGen } = require("./src/updateYearSecondGen");
const { downloadData } = require("./src/downloadData/downloadData");
const { connectUsersToActivities } = require("./src/connectUsersToActivities");
const { updateActivityUserCount } = require("./src/updateActivityUserCount");
const {
connectUsersToActivitiesSecondGen,
} = require("./src/connectUsersToActivitiesSecondGen");
const { firebaseConfig } = require("./config");
const { adminGetUserEmail } = require("./src/adminGetUserEmail");
const { updateUser } = require("./src/updateUser");
const { deletePostAfterOneYear } = require("./src/deletePostAfterOneYear");
admin.initializeApp(firebaseConfig);
const {
adminGetUserEmailSecondGen,
} = require("./src/adminGetUserEmailSecondGen");
const {
deletePostAfterOneYearSecondGen,
} = require("./src/deletePostAfterOneYearSecondGen");
initializeApp(firebaseConfig);
const {
updateActivityUserCountSecondGen,
} = require("./src/updateActivityUserCountSecondGen");
const { updateMonthSecondGen } = require("./src/updateMonthSecondGen");
const { updateUserSecondGen } = require("./src/updateUserSecondGen");

exports.createUserSecondGen = createUserSecondGen;
exports.deletePostAfterOneYearSecondGen = deletePostAfterOneYearSecondGen;
exports.connectUsersToActivitiesSecondGen = connectUsersToActivitiesSecondGen;
exports.adminGetUserEmailSecondGen = adminGetUserEmailSecondGen;
exports.updateActivityUserCountSecondGen = updateActivityUserCountSecondGen;

// Cloud functions
exports.createUser = createUser;
exports.deleteUser = deleteUser;
exports.updateMonth = updateMonth;
exports.updateYear = updateYear;
exports.assignAdminClaim = assignAdminClaim;
exports.updateMonthSecondGen = updateMonthSecondGen;
exports.updateUserSecondGen = updateUserSecondGen;
exports.updateYearSecondGen = updateYearSecondGen;
exports.downloadData = downloadData;
exports.connectUsersToActivities = connectUsersToActivities;
exports.updateActivityUserCount = updateActivityUserCount;
exports.adminGetUserEmail = adminGetUserEmail;
exports.updateUser = updateUser;
exports.deletePostAfterOneYear = deletePostAfterOneYear;
Loading
Loading