also upload protobufs to r2
This commit is contained in:
parent
d0d2773871
commit
72691403cd
|
@ -9,7 +9,7 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lingdocs/inflect": "7.0.3",
|
"@lingdocs/inflect": "7.0.7",
|
||||||
"base64url": "^3.0.1",
|
"base64url": "^3.0.1",
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"connect-redis": "^6.0.0",
|
"connect-redis": "^6.0.0",
|
||||||
|
@ -126,9 +126,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@lingdocs/inflect": {
|
"node_modules/@lingdocs/inflect": {
|
||||||
"version": "7.0.3",
|
"version": "7.0.7",
|
||||||
"resolved": "https://npm.lingdocs.com/@lingdocs/inflect/-/inflect-7.0.3.tgz",
|
"resolved": "https://npm.lingdocs.com/@lingdocs/inflect/-/inflect-7.0.7.tgz",
|
||||||
"integrity": "sha512-Ia4upjGHRUf6zuJ626V4g1AcaQQ5uKm8aHRn5qWYw1xEfBtSPHTvLd8Y6TXUjglv7HZ8udUXoP2LIGPWlD2aYA==",
|
"integrity": "sha512-I47qXKBqFNR1mRK5z5vKhd1hJrrdrKy0A0z1p+eCB8SFB1Np65rcalWIzJLH52JPoahCmTi8TxaBM85kV2j5lQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fp-ts": "^2.16.0",
|
"fp-ts": "^2.16.0",
|
||||||
"pbf": "^3.2.1",
|
"pbf": "^3.2.1",
|
||||||
|
@ -3109,9 +3109,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@lingdocs/inflect": {
|
"@lingdocs/inflect": {
|
||||||
"version": "7.0.3",
|
"version": "7.0.7",
|
||||||
"resolved": "https://npm.lingdocs.com/@lingdocs/inflect/-/inflect-7.0.3.tgz",
|
"resolved": "https://npm.lingdocs.com/@lingdocs/inflect/-/inflect-7.0.7.tgz",
|
||||||
"integrity": "sha512-Ia4upjGHRUf6zuJ626V4g1AcaQQ5uKm8aHRn5qWYw1xEfBtSPHTvLd8Y6TXUjglv7HZ8udUXoP2LIGPWlD2aYA==",
|
"integrity": "sha512-I47qXKBqFNR1mRK5z5vKhd1hJrrdrKy0A0z1p+eCB8SFB1Np65rcalWIzJLH52JPoahCmTi8TxaBM85kV2j5lQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"fp-ts": "^2.16.0",
|
"fp-ts": "^2.16.0",
|
||||||
"pbf": "^3.2.1",
|
"pbf": "^3.2.1",
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lingdocs/inflect": "7.0.3",
|
"@lingdocs/inflect": "7.0.7",
|
||||||
"base64url": "^3.0.1",
|
"base64url": "^3.0.1",
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"connect-redis": "^6.0.0",
|
"connect-redis": "^6.0.0",
|
||||||
|
|
2854
account/yarn.lock
2854
account/yarn.lock
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -14,8 +14,9 @@
|
||||||
},
|
},
|
||||||
"main": "lib/functions/src/index.js",
|
"main": "lib/functions/src/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@aws-sdk/client-s3": "^3.474.0",
|
||||||
"@google-cloud/storage": "^5.8.1",
|
"@google-cloud/storage": "^5.8.1",
|
||||||
"@lingdocs/inflect": "7.0.3",
|
"@lingdocs/inflect": "7.0.7",
|
||||||
"@types/cors": "^2.8.10",
|
"@types/cors": "^2.8.10",
|
||||||
"@types/google-spreadsheet": "^3.0.2",
|
"@types/google-spreadsheet": "^3.0.2",
|
||||||
"@types/react": "^18.0.21",
|
"@types/react": "^18.0.21",
|
||||||
|
|
|
@ -14,6 +14,16 @@ import {
|
||||||
import { getWordList } from "./word-list-maker";
|
import { getWordList } from "./word-list-maker";
|
||||||
import { PublishDictionaryResponse } from "../../website/src/types/functions-types";
|
import { PublishDictionaryResponse } from "../../website/src/types/functions-types";
|
||||||
import { Storage } from "@google-cloud/storage";
|
import { Storage } from "@google-cloud/storage";
|
||||||
|
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
|
||||||
|
const s3Client = new S3Client({
|
||||||
|
region: "auto",
|
||||||
|
endpoint: functions.config().r2.endpoint,
|
||||||
|
credentials: {
|
||||||
|
accessKeyId: functions.config().r2.access_key_id,
|
||||||
|
secretAccessKey: functions.config().r2.secret_access_key,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const storage = new Storage({
|
const storage = new Storage({
|
||||||
projectId: "lingdocs",
|
projectId: "lingdocs",
|
||||||
});
|
});
|
||||||
|
@ -221,20 +231,41 @@ function checkForErrors(
|
||||||
async function upload(content: Buffer | string, filename: string) {
|
async function upload(content: Buffer | string, filename: string) {
|
||||||
const isBuffer = typeof content !== "string";
|
const isBuffer = typeof content !== "string";
|
||||||
const file = storage.bucket(bucketName).file(filename);
|
const file = storage.bucket(bucketName).file(filename);
|
||||||
|
// upload to Google Cloud Storage (will be deprecated / removed)
|
||||||
|
const metadata = {
|
||||||
|
contentType: isBuffer
|
||||||
|
? "application/octet-stream"
|
||||||
|
: filename.endsWith(".json")
|
||||||
|
? "application/json"
|
||||||
|
: filename.endsWith(".xml")
|
||||||
|
? "application/xml"
|
||||||
|
: "text/plain; charset=UTF-8",
|
||||||
|
cacheControl: "no-cache",
|
||||||
|
};
|
||||||
await file.save(content, {
|
await file.save(content, {
|
||||||
gzip: isBuffer ? false : true,
|
gzip: isBuffer ? false : true,
|
||||||
predefinedAcl: "publicRead",
|
predefinedAcl: "publicRead",
|
||||||
metadata: {
|
metadata,
|
||||||
contentType: isBuffer
|
|
||||||
? "application/octet-stream"
|
|
||||||
: filename.endsWith(".json")
|
|
||||||
? "application/json"
|
|
||||||
: filename.endsWith(".xml")
|
|
||||||
? "application/xml"
|
|
||||||
: "text/plain; charset=UTF-8",
|
|
||||||
cacheControl: "no-cache",
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
// upload to r2 (new destination)
|
||||||
|
const Metadata = {
|
||||||
|
"Content-Type": isBuffer
|
||||||
|
? "application/octet-stream"
|
||||||
|
: filename.endsWith(".json")
|
||||||
|
? "application/json"
|
||||||
|
: filename.endsWith(".xml")
|
||||||
|
? "application/xml"
|
||||||
|
: "text/plain; charset=UTF-8",
|
||||||
|
"Cache-Control": "no-cache",
|
||||||
|
};
|
||||||
|
// TODO: GZIP FILES
|
||||||
|
const putObjectCommand = new PutObjectCommand({
|
||||||
|
Bucket: functions.config().r2.bucket_name,
|
||||||
|
Key: `dictionary/${filename}`,
|
||||||
|
Body: content,
|
||||||
|
Metadata,
|
||||||
|
});
|
||||||
|
await s3Client.send(putObjectCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
// async function uploadHunspellToStorage(wordlist: {
|
// async function uploadHunspellToStorage(wordlist: {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fortawesome/fontawesome-free": "^5.15.2",
|
"@fortawesome/fontawesome-free": "^5.15.2",
|
||||||
"@lingdocs/ps-react": "7.0.3",
|
"@lingdocs/ps-react": "7.0.7",
|
||||||
"@testing-library/jest-dom": "^5.11.4",
|
"@testing-library/jest-dom": "^5.11.4",
|
||||||
"@testing-library/react": "^11.1.0",
|
"@testing-library/react": "^11.1.0",
|
||||||
"@testing-library/user-event": "^12.1.10",
|
"@testing-library/user-event": "^12.1.10",
|
||||||
|
|
|
@ -2349,10 +2349,10 @@
|
||||||
"@jridgewell/resolve-uri" "^3.0.3"
|
"@jridgewell/resolve-uri" "^3.0.3"
|
||||||
"@jridgewell/sourcemap-codec" "^1.4.10"
|
"@jridgewell/sourcemap-codec" "^1.4.10"
|
||||||
|
|
||||||
"@lingdocs/ps-react@7.0.3":
|
"@lingdocs/ps-react@7.0.7":
|
||||||
version "7.0.3"
|
version "7.0.7"
|
||||||
resolved "https://npm.lingdocs.com/@lingdocs/ps-react/-/ps-react-7.0.3.tgz#9962fca6a7eeec1d9eec7938ca5fbf2c8634c228"
|
resolved "https://npm.lingdocs.com/@lingdocs/ps-react/-/ps-react-7.0.7.tgz#030d7b614027d944b4228cbeac67bffec206a1ff"
|
||||||
integrity sha512-/ASFFGudbqjEaZQ5OSHAwCQaZSdnPPInWv30rLR6ytLA+lS2udXLQHXkW+3ArUQ1UFBQlK1AC2+1tKNxvD2IrQ==
|
integrity sha512-H/md+cDteBPry8wrI0uvhQIdGz97BqwPollj3c8NANc7ryUGNS7wbwRA20ayGn7AaiwpERhu/1+VzW4YEqM8vw==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@formkit/auto-animate" "^1.0.0-beta.3"
|
"@formkit/auto-animate" "^1.0.0-beta.3"
|
||||||
classnames "^2.2.6"
|
classnames "^2.2.6"
|
||||||
|
|
Loading…
Reference in New Issue