Start http server to run in Cloud Run

This commit is contained in:
Jackson Harper 2023-01-11 16:57:00 +08:00
parent 6aabd0311f
commit e31a806fcb
3 changed files with 75 additions and 3 deletions

View file

@ -14,7 +14,7 @@
"lint": "eslint src --ext ts,js,tsx,jsx",
"compile": "tsc",
"build": "tsc",
"start_gcf": "npx functions-framework --port=9090 --target=puppeteer",
"start_gcf": "npx functions-framework --port=9090 --target=httpServer",
"dev": "concurrently \"tsc -w\" \"nodemon --watch ./build/ --exec npm run start\""
},
"devDependencies": {
@ -36,6 +36,7 @@
"@google-cloud/storage": "^5.18.1",
"@google-cloud/tasks": "^3.0.5",
"@omnivore/readability": "1.0.0",
"@sentry/serverless": "^7.30.0",
"@types/express": "^4.17.13",
"csv-parser": "^3.0.0",
"dompurify": "^2.4.3",
@ -45,4 +46,4 @@
"unzip-stream": "^0.3.1",
"urlsafe-base64": "^1.0.0"
}
}
}

View file

@ -14,6 +14,13 @@ import { promisify } from 'util'
import * as jwt from 'jsonwebtoken'
import { Readability } from '@omnivore/readability'
import Sentry from '@sentry/serverless'
Sentry.GCPFunction.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 0,
})
const signToken = promisify(jwt.sign)
const storage = new Storage()
@ -197,3 +204,9 @@ export const importHandler: EventFunction = async (event, context) => {
}
}
}
export const httpServer = Sentry.GCPFunction.wrapHttpFunction(
async (req, res) => {
res.send('ok')
}
)

View file

@ -5526,6 +5526,15 @@
"@sentry/utils" "6.19.6"
tslib "^1.9.3"
"@sentry/core@7.30.0":
version "7.30.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.30.0.tgz#02d2e8747484ba64b6d712e8afe6736250efdc26"
integrity sha512-NeLigkBlpcK63ymM63GoIHurml6V3BUe1Vi+trwm4/qqOTzT7PQhvdJCX+o3+atzRBH+zdb6kd4VWx44Oye3KA==
dependencies:
"@sentry/types" "7.30.0"
"@sentry/utils" "7.30.0"
tslib "^1.9.3"
"@sentry/hub@5.30.0":
version "5.30.0"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.30.0.tgz#2453be9b9cb903404366e198bd30c7ca74cdc100"
@ -5652,6 +5661,19 @@
lru_map "^0.3.3"
tslib "^1.9.3"
"@sentry/node@7.30.0":
version "7.30.0"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.30.0.tgz#42ef5b29d065f6de6ac5556a56aca20d3b9073e1"
integrity sha512-YYasu6C3I0HBP4N1oc/ed2nunxhGJgtAWaKwq3lo8uk3uF6cB1A8+2e0CpjzU5ejhbaFPUBxHyj4th39Bvku/w==
dependencies:
"@sentry/core" "7.30.0"
"@sentry/types" "7.30.0"
"@sentry/utils" "7.30.0"
cookie "^0.4.1"
https-proxy-agent "^5.0.0"
lru_map "^0.3.3"
tslib "^1.9.3"
"@sentry/node@^5.26.0":
version "5.30.0"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-5.30.0.tgz#4ca479e799b1021285d7fe12ac0858951c11cd48"
@ -5693,6 +5715,19 @@
"@types/express" "^4.17.2"
tslib "^1.9.3"
"@sentry/serverless@^7.30.0":
version "7.30.0"
resolved "https://registry.yarnpkg.com/@sentry/serverless/-/serverless-7.30.0.tgz#f639c835043de2c3dec10f3667fcf8545a557e24"
integrity sha512-Fs6fuyDR+RJ5yg/m4M9Ids+jVc9FJbE8XBxOGZkpYkjZFLWVETMI3tJt4cF31LOQF/irftr6pKW/blxHAknBrg==
dependencies:
"@sentry/node" "7.30.0"
"@sentry/tracing" "7.30.0"
"@sentry/types" "7.30.0"
"@sentry/utils" "7.30.0"
"@types/aws-lambda" "^8.10.62"
"@types/express" "^4.17.14"
tslib "^1.9.3"
"@sentry/tracing@5.30.0":
version "5.30.0"
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-5.30.0.tgz#501d21f00c3f3be7f7635d8710da70d9419d4e1f"
@ -5726,6 +5761,16 @@
"@sentry/utils" "6.19.6"
tslib "^1.9.3"
"@sentry/tracing@7.30.0":
version "7.30.0"
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-7.30.0.tgz#b4576fbaf81ce418f1b7c37e7e5f4f6cf19a3c3b"
integrity sha512-bjGeDeKhpGAmLcWcrXFT/xOfHVwp/j0L1aRHzYHnqgTjVzD0NXcooPu/Nz8vF0paxz+hPD5bJwb8kz/ggJzGWQ==
dependencies:
"@sentry/core" "7.30.0"
"@sentry/types" "7.30.0"
"@sentry/utils" "7.30.0"
tslib "^1.9.3"
"@sentry/tracing@^7.9.0":
version "7.9.0"
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-7.9.0.tgz#0cbbf5b61ee76b934d2e4160a0ad3daf0001237b"
@ -5756,6 +5801,11 @@
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.10.0.tgz#c91d634768336238ac30ed750fa918326c384cbb"
integrity sha512-1UBwdbS0xXzANzp63g4eNQly/qKIXp0swP5OTKWoADvKBtL4anroLUA/l8ADMtuwFZYtVANc8WRGxM2+YmaXtg==
"@sentry/types@7.30.0":
version "7.30.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.30.0.tgz#fc2baeb5b0e1ecc4d52b07b056fcba54449cd9ce"
integrity sha512-l4A86typvt/SfWh5JffpdxNGkg5EEA8m35BzpIcKmCAQZUDmnb4b478r8jdD2uuOjLmPNmZr1tifdRW4NCLuxQ==
"@sentry/types@7.9.0":
version "7.9.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.9.0.tgz#8fa952865fda76f7c7c7fc6c84043979a22043ae"
@ -5793,6 +5843,14 @@
"@sentry/types" "7.10.0"
tslib "^1.9.3"
"@sentry/utils@7.30.0":
version "7.30.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.30.0.tgz#1d83145399c65e31f725c1b6ae02f451a990f326"
integrity sha512-tSlBhr5u/LdE2emxIDTDmjmyRr99GnZGIAh5GwRxUgeDQ3VEfNUFlyFodBCbZ6yeYTYd6PWNih5xoHn1+Rf3Sw==
dependencies:
"@sentry/types" "7.30.0"
tslib "^1.9.3"
"@sentry/utils@7.9.0":
version "7.9.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.9.0.tgz#497c41efe1b32974208ca68570e42c853b874f77"
@ -8021,7 +8079,7 @@
dependencies:
"@types/express" "*"
"@types/express@*", "@types/express@^4.16.0", "@types/express@^4.17.13", "@types/express@^4.17.2", "@types/express@^4.17.7":
"@types/express@*", "@types/express@^4.16.0", "@types/express@^4.17.13", "@types/express@^4.17.14", "@types/express@^4.17.2", "@types/express@^4.17.7":
version "4.17.15"
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.15.tgz#9290e983ec8b054b65a5abccb610411953d417ff"
integrity sha512-Yv0k4bXGOH+8a+7bELd2PqHQsuiANB+A8a4gnQrkRWzrkKlb6KHaVvyXhqs04sVW/OWlbPyYxRgYlIXLfrufMQ==