Skip to content

Commit

Permalink
fix(developer): set v1 function settings with v1 methods
Browse files Browse the repository at this point in the history
  • Loading branch information
steveoh committed Jul 10, 2024
1 parent 11abc90 commit 247a376
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/developer/functions/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { debug } from 'firebase-functions/logger';
import { auth } from 'firebase-functions/v1'; // v2 does not support auth triggers as of july/23
import { runWith } from 'firebase-functions/v1';
import { https, setGlobalOptions } from 'firebase-functions/v2';
import { safelyInitializeApp } from './firebase.js';

safelyInitializeApp();

const serviceAccount = `firestore-function-sa@${process.env.GCLOUD_PROJECT}.iam.gserviceaccount.com`;
const vpcConnector = 'memorystore-connector';
const vpcConnectorEgressSettings = 'PRIVATE_RANGES_ONLY';

setGlobalOptions({
serviceAccount: `firestore-function-sa@${process.env.GCLOUD_PROJECT}.iam.gserviceaccount.com`,
vpcConnector: 'memorystore-connector',
vpcConnectorEgressSettings: 'PRIVATE_RANGES_ONLY',
serviceAccount,
vpcConnector,
vpcConnectorEgressSettings,
});

const cors = [
Expand All @@ -29,8 +33,12 @@ const cors = [
* @param {any} async(user - The user details from the OIDC flow from Utahid.
* @returns {bool} - The true or false result of the create user method.
*/
export const onCreateUser = auth
.user({
export const onCreateUser = runWith({
serviceAccount,
vpcConnector,
vpcConnectorEgressSettings,
})
.auth.user({
secrets: ['SENDGRID_API_KEY'],
})
.onCreate(async (user) => {
Expand Down

0 comments on commit 247a376

Please sign in to comment.