Skip to content

Commit

Permalink
Merge pull request #52 from supabase-community/fix-cdn
Browse files Browse the repository at this point in the history
fix: remove filtering by a event name
  • Loading branch information
mats16 authored Jun 30, 2023
2 parents 2b5bed8 + 9aef361 commit 4a9e4a2
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ _Launch in minutes. Scale to millions._

This repo includes a template of starting Supabase stack on AWS via CloudFormation/CDK. This template use managed services such as Amazon ECS and Amazon Aurora etc...

## Architecture

![architecture-diagram](docs/images/architecture-diagram.png)

![smart-cdn-caching](docs/images/smart-cdn-caching.png)

## Deploy via CloudFormation template

| Region | View | Stable | Latest |
Expand Down
Binary file modified docs/images/architecture-diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/smart-cdn-caching.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 6 additions & 5 deletions src/supabase-cdn/cache-manager/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import { handle } from 'hono/aws-lambda';
import { bearerAuth } from 'hono/bearer-auth';
import { WebhookEvent } from './types';

/** AWS region */
const region = process.env.AWS_REGION;
/** SQS queue URL */
const queueUrl = process.env.QUEUE_URL;
/** Bearer token */
const token = process.env.API_KEY!;
const eventList = process.env.EVENT_LIST!.split(',');

const logger = new Logger();
const tracer = new Tracer();
Expand All @@ -26,7 +28,8 @@ const enqueue = async (message: object) => {
QueueUrl: queueUrl,
MessageBody: JSON.stringify(message),
});
await sqs.send(cmd);
const output = await sqs.send(cmd);
return output;
};

/** Hono app */
Expand All @@ -37,9 +40,7 @@ app.post('/', bearerAuth({ token }), async (c) => {
const body: WebhookEvent = await c.req.json();
console.log(JSON.stringify(body));

if (eventList.includes(body.event.type)) {
await enqueue(body);
}
await enqueue(body);
return c.text('Accepted', 202);
});

Expand Down
5 changes: 0 additions & 5 deletions src/supabase-cdn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,6 @@ class CacheManager extends Construct {
environment: {
QUEUE_URL: queue.queueUrl,
API_KEY: this.apiKey.secretValue.toString(),
EVENT_LIST: [
'ObjectRemoved:Delete',
'ObjectRemoved:Move',
'ObjectUpdated:Metadata',
].join(','),
},
tracing: lambda.Tracing.ACTIVE,
});
Expand Down
3 changes: 1 addition & 2 deletions test/__snapshots__/main.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4a9e4a2

Please sign in to comment.