Skip to content

Commit

Permalink
fix(function): admin app import
Browse files Browse the repository at this point in the history
  • Loading branch information
hlolli committed Dec 10, 2024
1 parent de544f9 commit 8e57240
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 15 deletions.
3 changes: 2 additions & 1 deletion functions/src/add_project_file_on_storage_upload.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import admin from "firebase-admin";
import { initializeApp } from "firebase-admin/app";
import { onObjectFinalized } from "firebase-functions/v2/storage";
import { makeLogger } from "./logger.js";

admin.initializeApp(); // ensure this is done somewhere in your setup
initializeApp(); // ensure this is done somewhere in your setup
const log = makeLogger("addProjectFileOnStorageUpload");
const newTimestamp = admin.firestore.FieldValue.serverTimestamp();

Expand Down
5 changes: 3 additions & 2 deletions functions/src/delete_user.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import * as admin from "firebase-admin";
import admin from "firebase-admin";
import { initializeApp } from "firebase-admin/app";
import functions from "firebase-functions/v1";
import { makeLogger } from "./logger.js";

const log = makeLogger("deleteUser");

admin.initializeApp();
initializeApp();

const deleteUserDocument = async (
user: admin.auth.UserRecord
Expand Down
5 changes: 3 additions & 2 deletions functions/src/followers_counter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as admin from "firebase-admin";
import admin from "firebase-admin";
import { initializeApp } from "firebase-admin/app";
import { onDocumentWritten } from "firebase-functions/v2/firestore";
import { makeLogger } from "./logger.js";

admin.initializeApp();
initializeApp();
const log = makeLogger("followersCounter");

export const followersCounter = onDocumentWritten(
Expand Down
5 changes: 3 additions & 2 deletions functions/src/following_counter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as admin from "firebase-admin";
import admin from "firebase-admin";
import { initializeApp } from "firebase-admin/app";
import { onDocumentWritten } from "firebase-functions/v2/firestore";
import { makeLogger } from "./logger.js";

admin.initializeApp();
initializeApp();
const log = makeLogger("followersCounter");

export const followingCounter = onDocumentWritten(
Expand Down
5 changes: 3 additions & 2 deletions functions/src/host.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as admin from "firebase-admin";
import admin from "firebase-admin";
import { initializeApp } from "firebase-admin/app";
import { onRequest } from "firebase-functions/v2/https";
import { isbot } from "isbot";
import fs from "node:fs";
import path from "node:path";
import * as R from "ramda";

admin.initializeApp();
initializeApp();

function printTree(dirPath: string, indent = "") {
const files = fs.readdirSync(dirPath);
Expand Down
5 changes: 3 additions & 2 deletions functions/src/new_user.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { WriteResult } from "@google-cloud/firestore";
import { Timestamp } from "firebase-admin/firestore";
import * as admin from "firebase-admin";
import admin from "firebase-admin";
import { initializeApp } from "firebase-admin/app";
import functions from "firebase-functions/v1";
import { makeLogger } from "./logger.js";

admin.initializeApp();
initializeApp();
const log = makeLogger("newUser");

async function createProfileDocument(
Expand Down
5 changes: 3 additions & 2 deletions functions/src/project_file_storage_delete.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as admin from "firebase-admin";
import admin from "firebase-admin";
import { initializeApp } from "firebase-admin/app";
import { onDocumentDeleted } from "firebase-functions/v2/firestore";
import { config } from "firebase-functions/v1";
import { makeLogger } from "./logger.js";

admin.initializeApp();
initializeApp();
const log = makeLogger("projectFileStorageDelete");

async function projectFileStorageDelete(binaryUrl: string): Promise<void> {
Expand Down
5 changes: 3 additions & 2 deletions functions/src/projects_counter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as admin from "firebase-admin";
import admin from "firebase-admin";
import { initializeApp } from "firebase-admin/app";
import { FieldValue } from "firebase-admin/firestore";
import { onDocumentWritten } from "firebase-functions/v2/firestore";
import { makeLogger } from "./logger.js";

admin.initializeApp();
initializeApp();
const log = makeLogger("projectsCounter");

export const projectsCounter = onDocumentWritten(
Expand Down

0 comments on commit 8e57240

Please sign in to comment.