-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(storage-image-processing-api): initial extension build (#2)
Co-authored-by: Mike Diarmid <mike.diarmid@gmail.com> Co-authored-by: Darren Ackers <darren@invertase.io>
- Loading branch information
Showing
69 changed files
with
21,673 additions
and
7,717 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# editorconfig | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
# Use the below to use a specific branch of firebase-tools | ||
# git clone --single-branch --branch jh-ext-emu-fixes https://github.com/firebase/firebase-tools.git | ||
# cd firebase-tools | ||
# npm i | ||
# npm link --local | ||
npm i -g firebase-tools@latest | ||
firebase --open-sesame extdev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: storage-image-processing-api | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- "extensions/storage-image-processing-api/**" | ||
- ".github/workflows/storage-image-processing-api.yaml" | ||
|
||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- "docs/**" | ||
- "**.md" | ||
|
||
env: | ||
EXTENSION_PATH: "extensions/storage-image-processing-api" | ||
|
||
jobs: | ||
e2e: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2-beta | ||
with: | ||
node-version: '14' | ||
- name: NPM Install | ||
run: npm install | ||
- name: Install Firebase CLI | ||
run: ./.github/workflows/scripts/install-firebase-cli.sh | ||
- name: Jest Tests | ||
run: | | ||
cd $EXTENSION_PATH/functions | ||
npm run emulator & | ||
sleep 10 | ||
npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
build | ||
lib | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ | |
"bracketSpacing": true, | ||
"jsxBracketSameLine": false, | ||
"tabWidth": 2, | ||
"printWidth": 100 | ||
"printWidth": 80 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Image Processing API | ||
|
||
**Author**: Invertase (**[https://invertase.io](https://invertase.io)**) | ||
|
||
**Description**: TODO | ||
|
||
**Configuration Parameters:** | ||
|
||
- Cloud Functions location: Where do you want to deploy the functions created for this extension? You usually want a location close to your Storage bucket. For help selecting a location, refer to the [location selection guide](https://firebase.google.com/docs/functions/locations). | ||
|
||
- Cloud Storage bucket for images: The Cloud Storage bucket where images that are to be processed are located. API requests with input urls or paths that are not inside this bucket will be dropped. | ||
|
||
- Allowed CORS origins.: A comma delimited value of allowed CORS origins. Use the default of '\*' to allow all origins. This is useful to lockdown your API and only allow your own website to embed the images directly. Note this will not prevent non-browser requests from accessing your API. | ||
|
||
- Cloud Storage path where processed images will be cached.: A relative path in which to store cached images. For example, `cache`. If you prefer to store resized images at the default location, leave this field empty. | ||
|
||
**Cloud Functions:** | ||
|
||
- **api:** TODO | ||
|
||
**APIs Used**: | ||
|
||
- storage-component.googleapis.com (Reason: Needed to use Cloud Storage) | ||
|
||
**Access Required**: | ||
|
||
This extension will operate with the following project IAM roles: | ||
|
||
- storage.admin (Reason: Allows the extension to store resized images in Cloud Storage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
name: storage-image-processing-api | ||
version: 0.0.1 | ||
specVersion: v1beta | ||
|
||
displayName: Image Processing API | ||
description: TODO | ||
|
||
license: Apache-2.0 | ||
|
||
sourceUrl: https://github.com/invertase/firebase-extensions/tree/main/extensions/storage-image-processing-api | ||
releaseNotesUrl: https://github.com/invertase/firebase-extensions/tree/main/extensions/storage-image-processing-api/CHANGELOG.md | ||
|
||
author: | ||
authorName: Invertase | ||
url: https://invertase.io | ||
|
||
contributors: | ||
- authorName: Invertase | ||
email: oss@invertase.io | ||
url: https://github.com/invertase | ||
|
||
billingRequired: true | ||
|
||
apis: | ||
- apiName: storage-component.googleapis.com | ||
reason: Needed to use Cloud Storage | ||
|
||
roles: | ||
- role: storage.admin | ||
reason: Allows the extension to store resized images in Cloud Storage | ||
|
||
resources: | ||
- name: handler | ||
type: firebaseextensions.v1beta.function | ||
description: >- | ||
TODO | ||
properties: | ||
location: ${param:LOCATION} | ||
runtime: nodejs14 | ||
availableMemoryMb: 1024 | ||
httpsTrigger: {} | ||
|
||
params: | ||
- param: LOCATION | ||
label: Cloud Functions location | ||
description: >- | ||
Where do you want to deploy the functions created for this extension? | ||
You usually want a location close to your Storage bucket. For help selecting a | ||
location, refer to the [location selection | ||
guide](https://firebase.google.com/docs/functions/locations). | ||
type: select | ||
options: | ||
- label: Iowa (us-central1) | ||
value: us-central1 | ||
- label: South Carolina (us-east1) | ||
value: us-east1 | ||
- label: Northern Virginia (us-east4) | ||
value: us-east4 | ||
- label: Los Angeles (us-west2) | ||
value: us-west2 | ||
- label: Salt Lake City (us-west3) | ||
value: us-west3 | ||
- label: Las Vegas (us-west4) | ||
value: us-west4 | ||
- label: Warsaw (europe-central2) | ||
value: europe-central2 | ||
- label: Belgium (europe-west1) | ||
value: europe-west1 | ||
- label: London (europe-west2) | ||
value: europe-west2 | ||
- label: Frankfurt (europe-west3) | ||
value: europe-west3 | ||
- label: Zurich (europe-west6) | ||
value: europe-west6 | ||
- label: Hong Kong (asia-east2) | ||
value: asia-east2 | ||
- label: Tokyo (asia-northeast1) | ||
value: asia-northeast1 | ||
- label: Osaka (asia-northeast2) | ||
value: asia-northeast2 | ||
- label: Seoul (asia-northeast3) | ||
value: asia-northeast3 | ||
- label: Mumbai (asia-south1) | ||
value: asia-south1 | ||
- label: Jakarta (asia-southeast2) | ||
value: asia-southeast2 | ||
- label: Montreal (northamerica-northeast1) | ||
value: northamerica-northeast1 | ||
- label: Sao Paulo (southamerica-east1) | ||
value: southamerica-east1 | ||
- label: Sydney (australia-southeast1) | ||
value: australia-southeast1 | ||
default: us-central1 | ||
required: true | ||
immutable: true | ||
|
||
- param: CLOUD_STORAGE_BUCKET | ||
label: Cloud Storage bucket for images | ||
description: > | ||
The Cloud Storage bucket where images that are to be processed are located. | ||
API requests with input urls or paths that are not inside this bucket will be | ||
dropped. | ||
type: string | ||
example: my-project-12345.appspot.com | ||
validationRegex: ^([0-9a-z_.-]*)$ | ||
validationErrorMessage: Invalid storage bucket | ||
default: ${param:STORAGE_BUCKET} | ||
required: true | ||
|
||
- param: CORS_ORIGIN_ALLOW_LIST | ||
label: Allowed CORS origins. | ||
description: > | ||
A comma delimited value of allowed CORS origins. Use the default of '*' | ||
to allow all origins. This is useful to lockdown your API and only allow | ||
your own website to embed the images directly. Note this will not | ||
prevent non-browser requests from accessing your API. | ||
type: string | ||
example: '*.example.com,invertase.io' | ||
default: '*' | ||
required: true | ||
|
||
- param: CACHED_IMAGES_PATH | ||
label: Cloud Storage path where processed images will be cached. | ||
description: > | ||
A relative path in which to store cached images. For example, | ||
`cache`. If you prefer to store resized images at the default | ||
location, leave this field empty. | ||
example: processed_images_cache | ||
required: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Compiled JavaScript files | ||
lib/**/*.js | ||
lib/**/*.js.map | ||
assets/*_output.* | ||
test-params.env |
7 changes: 7 additions & 0 deletions
7
...sions/storage-image-processing-api/functions/__tests__/data/firebase-export-metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"version": "9.14.0", | ||
"storage": { | ||
"version": "9.14.0", | ||
"path": "storage_export" | ||
} | ||
} |
Binary file added
BIN
+2.09 KB
...tests__/data/storage_export/blobs/extensions-testing.appspot.com/invertase.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.79 KB
...ns/__tests__/data/storage_export/blobs/extensions-testing.appspot.com/melos.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.1 KB
...ons/__tests__/data/storage_export/blobs/extensions-testing.appspot.com/meow.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions
7
extensions/storage-image-processing-api/functions/__tests__/data/storage_export/buckets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"buckets": [ | ||
{ | ||
"id": "extensions-testing.appspot.com" | ||
} | ||
] | ||
} |
17 changes: 17 additions & 0 deletions
17
...__tests__/data/storage_export/metadata/extensions-testing.appspot.com/invertase.jpeg.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "invertase.jpeg", | ||
"bucket": "extensions-testing.appspot.com", | ||
"contentType": "image/jpeg", | ||
"metageneration": 1, | ||
"generation": 1625834405328, | ||
"storageClass": "STANDARD", | ||
"etag": "someETag", | ||
"contentDisposition": "inline", | ||
"contentEncoding": "identity", | ||
"downloadTokens": ["45270e94-bc47-4329-b0ba-1f6191f1ec21"], | ||
"timeCreated": "2021-07-09T12:40:05.327Z", | ||
"updated": "2021-07-09T12:40:05.328Z", | ||
"size": 2136, | ||
"md5Hash": "v0oknyXSaqPKi3rQ6azoCQ==", | ||
"crc32c": "3476354297" | ||
} |
17 changes: 17 additions & 0 deletions
17
...ions/__tests__/data/storage_export/metadata/extensions-testing.appspot.com/melos.png.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "melos.png", | ||
"bucket": "extensions-testing.appspot.com", | ||
"contentType": "image/png", | ||
"metageneration": 1, | ||
"generation": 1625834405346, | ||
"storageClass": "STANDARD", | ||
"etag": "someETag", | ||
"contentDisposition": "inline", | ||
"contentEncoding": "identity", | ||
"downloadTokens": ["1a9a5700-3336-4043-8ec4-f5a5b6df9b28"], | ||
"timeCreated": "2021-07-09T12:40:05.345Z", | ||
"updated": "2021-07-09T12:40:05.346Z", | ||
"size": 7975, | ||
"md5Hash": "+xjWjVWAj1pvKDT89EACzQ==", | ||
"crc32c": "1920535852" | ||
} |
Oops, something went wrong.