Skip to content

Commit

Permalink
chore(storage-image-processing-api): initial extension build (#2)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Diarmid <mike.diarmid@gmail.com>
Co-authored-by: Darren Ackers <darren@invertase.io>
  • Loading branch information
Salakar and dackers86 committed Jul 14, 2021
1 parent ee982e9 commit 7fc119e
Show file tree
Hide file tree
Showing 69 changed files with 21,673 additions and 7,717 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
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
8 changes: 8 additions & 0 deletions .github/workflows/scripts/install-firebase-cli.sh
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
37 changes: 37 additions & 0 deletions .github/workflows/storage-image-processing-api.yaml
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
23 changes: 6 additions & 17 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,14 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
with:
node-version: '12'
node-version: '14'
- name: NPM Install
run: yarn
run: npm install
- name: Check Linting
run: yarn run check:linting
run: npm run check:linting
- name: Check Formatting
run: yarn run check:formatting
run: npm run check:formatting
- name: Check TS Compiles
run: yarn run check:typescript
run: npm run check:typescript
- name: Check Spelling & Grammar
run: yarn run check:spelling
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
with:
node-version: '12'
- name: NPM Install
run: yarn
- name: Jest Tests
run: yarn run test
run: npm run check:spelling
40 changes: 9 additions & 31 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,36 +72,14 @@ typings/
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

.idea
spelling.json

# Firebase Logs
firebase-debug.log*
firebase-debug.*.log*

# Firebase cache
.firebase/
.DS_Store
yarn.lock
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
build
lib
package-lock.json
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"bracketSpacing": true,
"jsxBracketSameLine": false,
"tabWidth": 2,
"printWidth": 100
"printWidth": 80
}
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ A collection of Firebase Extensions built by Invertase.

> New to Extensions? You can learn more at the [Firebase Extensions product page](https://firebase.google.com/products/extensions).
Each directory in extensions folder of this repo contains the source code for an extension, and a README that explains
how the extension works, including information about the APIs enabled, resources created, and the access granted to the extension.
Each directory in the `/extensions` folder of this repository contains the source code for a Firebase Extension with a
README that explains how the extension works, including information about the APIs enabled, resources created, and the
access granted to the extension.

## List of Extensions

> Want to install one of these? Visit each extension's linked README for installation instructions.
> TODO
### [Image Processing API](/extensions/storage-image-processing-api)

Optimize and transform images from your Cloud Storage buckets via a powerful HTTP API. Supports over 30 different image
operations to optimize and manipulate your images.

---

Expand Down
File renamed without changes.
Empty file.
Empty file.
29 changes: 29 additions & 0 deletions extensions/storage-image-processing-api/README.md
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)
129 changes: 129 additions & 0 deletions extensions/storage-image-processing-api/extension.yaml
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
5 changes: 5 additions & 0 deletions extensions/storage-image-processing-api/functions/.gitignore
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
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"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"buckets": [
{
"id": "extensions-testing.appspot.com"
}
]
}
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"
}
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"
}

0 comments on commit 7fc119e

Please sign in to comment.