chore(functions): remove request dependency (#3673)

This commit is contained in:
Eva Killenberg
2024-06-18 06:59:42 -04:00
committed by GitHub
parent d7dc9b2f80
commit bad3b83049
3 changed files with 20 additions and 42 deletions

View File

@@ -31,7 +31,6 @@
"google-auth-library": "^9.10.0", "google-auth-library": "^9.10.0",
"handlebars": "^4.7.8", "handlebars": "^4.7.8",
"oa-shared": "workspace:*", "oa-shared": "workspace:*",
"request": "^2.88.2",
"sitemap": "^7.1.1", "sitemap": "^7.1.1",
"uuid": "^9.0.1" "uuid": "^9.0.1"
}, },
@@ -42,7 +41,6 @@
"@types/fs-extra": "^11.0.4", "@types/fs-extra": "^11.0.4",
"@types/jest": "^29.5.12", "@types/jest": "^29.5.12",
"@types/node": "^20.8.0", "@types/node": "^20.8.0",
"@types/request": "^2.48.12",
"@types/uuid": "^9.0.0", "@types/uuid": "^9.0.0",
"@types/webpack": "^5.28.5", "@types/webpack": "^5.28.5",
"@types/webpack-node-externals": "^3.0.4", "@types/webpack-node-externals": "^3.0.4",

View File

@@ -1,6 +1,6 @@
import { CONFIG } from '../config/config' import { CONFIG } from '../config/config'
import * as functions from 'firebase-functions' import * as functions from 'firebase-functions'
import * as request from 'request' import axios from 'axios'
import { IModerationStatus } from 'oa-shared' import { IModerationStatus } from 'oa-shared'
const SITE_URL = CONFIG.deployment.site_url const SITE_URL = CONFIG.deployment.site_url
@@ -11,7 +11,7 @@ const SLACK_WEBHOOK_URL = CONFIG.integrations.slack_webhook
export const notifyNewPin = functions export const notifyNewPin = functions
.runWith({ memory: '512MB' }) .runWith({ memory: '512MB' })
.firestore.document('v3_mappins/{pinId}') .firestore.document('v3_mappins/{pinId}')
.onCreate((snapshot) => { .onCreate(async (snapshot) => {
const info = snapshot.data() const info = snapshot.data()
const id = info._id const id = info._id
const type = info.type const type = info.type
@@ -19,48 +19,30 @@ export const notifyNewPin = functions
if (moderation !== IModerationStatus.AWAITING_MODERATION) return if (moderation !== IModerationStatus.AWAITING_MODERATION) return
request.post( return await axios
SLACK_WEBHOOK_URL, .post(SLACK_WEBHOOK_URL, {
{
json: {
text: `📍 *New ${type}* pin from _${id}_ awaiting moderation. \n Location here ${SITE_URL}/map/#${id}`, text: `📍 *New ${type}* pin from _${id}_ awaiting moderation. \n Location here ${SITE_URL}/map/#${id}`,
}, })
}, .catch((err) => {
(err, res) => {
if (err) {
console.error(err) console.error(err)
return })
} else {
return res
}
},
)
}) })
export const notifyNewHowTo = functions export const notifyNewHowTo = functions
.runWith({ memory: '512MB' }) .runWith({ memory: '512MB' })
.firestore.document('v3_howtos/{id}') .firestore.document('v3_howtos/{id}')
.onCreate((snapshot) => { .onCreate(async (snapshot) => {
const info = snapshot.data() const info = snapshot.data()
const user = info._createdBy const user = info._createdBy
const title = info.title const title = info.title
const slug = info.slug const slug = info.slug
// console.log(info);
request.post( return await axios
SLACK_WEBHOOK_URL, .post(SLACK_WEBHOOK_URL, {
{
json: {
text: `📓 Yeah! New How To *${title}* by _${user}_ awaiting moderation, text: `📓 Yeah! New How To *${title}* by _${user}_ awaiting moderation,
check it out: ${SITE_URL}/how-to/${slug}`, check it out: ${SITE_URL}/how-to/${slug}`,
}, })
}, .catch((err) => {
(err, res) => { console.error(err)
if (err) { })
console.error(err)
return
} else {
return res
}
},
)
}) })

View File

@@ -9044,7 +9044,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/request@npm:^2.48.12, @types/request@npm:^2.48.8": "@types/request@npm:^2.48.8":
version: 2.48.12 version: 2.48.12
resolution: "@types/request@npm:2.48.12" resolution: "@types/request@npm:2.48.12"
dependencies: dependencies:
@@ -17327,7 +17327,6 @@ __metadata:
"@types/fs-extra": ^11.0.4 "@types/fs-extra": ^11.0.4
"@types/jest": ^29.5.12 "@types/jest": ^29.5.12
"@types/node": ^20.8.0 "@types/node": ^20.8.0
"@types/request": ^2.48.12
"@types/uuid": ^9.0.0 "@types/uuid": ^9.0.0
"@types/webpack": ^5.28.5 "@types/webpack": ^5.28.5
"@types/webpack-node-externals": ^3.0.4 "@types/webpack-node-externals": ^3.0.4
@@ -17349,7 +17348,6 @@ __metadata:
jest: 29.7.0 jest: 29.7.0
jest-junit: ^16.0.0 jest-junit: ^16.0.0
oa-shared: "workspace:*" oa-shared: "workspace:*"
request: ^2.88.2
sitemap: ^7.1.1 sitemap: ^7.1.1
supertest: ^6.3.3 supertest: ^6.3.3
ts-jest: 29.1.4 ts-jest: 29.1.4
@@ -27024,7 +27022,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"request@npm:^2.87.0, request@npm:^2.88.2": "request@npm:^2.87.0":
version: 2.88.2 version: 2.88.2
resolution: "request@npm:2.88.2" resolution: "request@npm:2.88.2"
dependencies: dependencies: