Skip to content

Commit

Permalink
Initial Hono + D1 rewrite
Browse files Browse the repository at this point in the history
Worker has been rewritten to use Hono router and Cloudflare D1 storage with Drizzle ORM
  • Loading branch information
jake-walker committed Jan 27, 2024
1 parent 871c68e commit a9c6ee3
Show file tree
Hide file tree
Showing 29 changed files with 4,842 additions and 4,007 deletions.
17 changes: 1 addition & 16 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ jobs:
cypress-run:
runs-on: ubuntu-latest
services:
dynamodb:
image: amazon/dynamodb-local:latest
ports:
- 8000:8000
minio:
image: bitnami/minio:latest
env:
Expand All @@ -22,7 +18,7 @@ jobs:
- name: Setup Node
uses: actions/[email protected]
with:
node-version: 16
node-version: 20
- name: Get cache directory
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand All @@ -34,13 +30,6 @@ jobs:
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Create DynamoDB Table
uses: giboow/action-aws-cli@v1
with:
args: dynamodb --endpoint-url http://dynamodb:8000 create-table --region eu-west-1 --table-name vh7 --key-schema AttributeName=id,KeyType=HASH --attribute-definitions AttributeName=id,AttributeType=S --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1
env:
AWS_ACCESS_KEY_ID: testid
AWS_SECRET_ACCESS_KEY: testkey
- name: Create S3 Bucket
uses: giboow/action-aws-cli@v1
with:
Expand All @@ -62,10 +51,6 @@ jobs:
S3_DEFAULT_REGION: eu-west-1
S3_ENDPOINT_URL: http://localhost:9000
S3_BUCKET: vh7-uploads
DYNAMODB_ACCESS_KEY_ID: testid
DYNAMODB_SECRET_ACCESS_KEY: testkey
DYNAMODB_TABLE: vh7
DYNAMODB_ENDPOINT_URL: http://localhost:8000
VH7_ENV: testing
SENTRY_DSN: ${{ secrets.WORKER_SENTRY_DSN }}
SENTRY_CLIENT_ID: ${{ secrets.WORKER_SENTRY_CLIENT_ID }}
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Setup Node
uses: actions/[email protected]
with:
node-version: 16
node-version: 20
- name: Get cache directory
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand All @@ -27,16 +27,13 @@ jobs:
working-directory: ./worker
run: |
yarn install --dev
yarn global add @cloudflare/wrangler
yarn global add wrangler
- name: Lint
working-directory: ./worker
run: yarn run lint
# - name: Test
# working-directory: ./worker
# run: yarn run test
- name: Build
- name: Test
working-directory: ./worker
run: wrangler build
run: yarn run test
deploy:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,4 @@ accessgrant.txt
cleanup/backup-*
app/cypress/downloads
cleanup/prod.env
.wrangler
25 changes: 0 additions & 25 deletions cleanup/config.js

This file was deleted.

89 changes: 0 additions & 89 deletions cleanup/index.js

This file was deleted.

12 changes: 0 additions & 12 deletions cleanup/package.json

This file was deleted.

13 changes: 0 additions & 13 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
version: '3.8'
services:
dynamodb:
image: amazon/dynamodb-local:latest
ports:
- "8100:8000"
init-dynamodb:
image: amazon/aws-cli:latest
command: "dynamodb --endpoint-url http://dynamodb:8000 create-table --region eu-west-1 --table-name vh7 --key-schema AttributeName=id,KeyType=HASH --attribute-definitions AttributeName=id,AttributeType=S --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 > /dev/null"
environment:
- "AWS_ACCESS_KEY_ID=DUMMYIDEXAMPLE"
- "AWS_SECRET_ACCESS_KEY=DUMMYEXAMPLEKEY"
depends_on:
dynamodb:
condition: service_started
minio:
image: minio/minio:latest
command: "server /data -console-address ':9001'"
Expand Down
28 changes: 28 additions & 0 deletions worker/drizzle/0000_fair_donald_blake.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
CREATE TABLE short_link_paste (
`short_link_id` text PRIMARY KEY NOT NULL,
`code` text NOT NULL,
`language` text,
FOREIGN KEY (`short_link_id`) REFERENCES short_link(`id`)
);

CREATE TABLE short_link_upload (
`short_link_id` text PRIMARY KEY NOT NULL,
`filename` text NOT NULL,
`size` integer NOT NULL,
`hash` text NOT NULL,
FOREIGN KEY (`short_link_id`) REFERENCES short_link(`id`)
);

CREATE TABLE short_link_url (
`short_link_id` text PRIMARY KEY NOT NULL,
`url` text NOT NULL,
FOREIGN KEY (`short_link_id`) REFERENCES short_link(`id`)
);

CREATE TABLE short_link (
`id` text PRIMARY KEY NOT NULL,
`created_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL,
`updated_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL,
`expires_at` integer,
`type` text NOT NULL
);
Loading

0 comments on commit a9c6ee3

Please sign in to comment.