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

fix: bump dependencies and switch node runtime #47

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.0] - 2024-04-26

Dependencies bump.
Use nodejs18 runtime.

## [0.2.0] - 2021-11-23

Set Messagebird API Key parameter type to `secret` so it is stored in Cloud Secret Manager, dependencies bump
Set MessageBird API Key parameter type to `secret` so it is stored in Cloud Secret Manager, dependencies bump

## [0.1.8] - 2021-08-13

Expand Down
2 changes: 1 addition & 1 deletion __tests__/__snapshots__/functions.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`firestore-messagebird-send-msg functions configuration detected from environment variables 1`] = `
Object {
{
"accessKey": "aaa",
"location": "europe-west1",
"logLevel": "warn",
Expand Down
4 changes: 3 additions & 1 deletion __tests__/functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ jest.mock("firebase-admin", () => ({
},
}));

jest.mock("messagebird", () => () => ({
jest.mock("messagebird", () => ({
initClient: () => ({
conversations: {
start: (payload, callback) => {
callback(null, { id: "fakeConversationsResponse" });
},
},
})
}));

describe("firestore-messagebird-send-msg", () => {
Expand Down
2 changes: 1 addition & 1 deletion extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ resources:
properties:
sourceDirectory: .
location: ${LOCATION}
runtime: nodejs10
runtime: nodejs18
eventTrigger:
eventType: providers/cloud.firestore/eventTypes/document.write
resource: projects/${PROJECT_ID}/databases/(default)/documents/${MSG_COLLECTION}/{id}
Expand Down
10 changes: 7 additions & 3 deletions functions/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand Down Expand Up @@ -52,7 +56,7 @@ function initialize() {
(0, log_1.logInfo)("initializing db...");
db = admin.firestore();
(0, log_1.logInfo)("initializing mb api client...");
mb = (0, messagebird_1.default)(config_1.default.accessKey, undefined, ["ENABLE_FIREBASE_PLUGIN"]);
mb = messagebird_1.default.initClient(config_1.default.accessKey, undefined, ["ENABLE_FIREBASE_PLUGIN"]);
(0, log_1.logInfo)("initialization finished successfully");
}
function deliver(payload, ref) {
Expand Down Expand Up @@ -165,7 +169,7 @@ function processWrite(change) {
}
});
}
exports.processQueue = functions.handler.firestore.document.onWrite((change) => __awaiter(void 0, void 0, void 0, function* () {
exports.processQueue = functions.firestore.document(config_1.default.msgCollection + '/{msgId}').onWrite((change) => __awaiter(void 0, void 0, void 0, function* () {
initialize();
try {
yield processWrite(change);
Expand Down
4 changes: 2 additions & 2 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function initialize() {
logInfo("initializing db...");
db = admin.firestore();
logInfo("initializing mb api client...");
mb = messagebird(config.accessKey, undefined, ["ENABLE_FIREBASE_PLUGIN"]);
mb = messagebird.initClient(config.accessKey, undefined, ["ENABLE_FIREBASE_PLUGIN"]);
logInfo("initialization finished successfully");
}

Expand Down Expand Up @@ -164,7 +164,7 @@ async function processWrite(
}
}

export const processQueue = functions.handler.firestore.document.onWrite(
export const processQueue = functions.firestore.document(config.msgCollection + '/{msgId}').onWrite(
async (change) => {
initialize();
try {
Expand Down
Loading
Loading