Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use submit endpoint when authorised #22

Merged
merged 18 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

DATABASE_URL=./.wrangler/state/d1/DB.sqlite3
8 changes: 5 additions & 3 deletions .github/workflows/buildAndDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ on:
push:
branches:
- main
- feature/authorization-header
- feature/new-router
- feature/direct-submit
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: npx prisma generate
- name: Publish
uses: cloudflare/wrangler-action@v3
with:
Expand Down
13 changes: 13 additions & 0 deletions migrations/0001_init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Migration number: 0001 2024-05-09T09:28:45.679Z

-- CreateTable
CREATE TABLE "Submissions" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"url" TEXT NOT NULL,
"state" INTEGER NOT NULL DEFAULT 0,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"ip_address" TEXT,
"country" TEXT,
"user_agent" TEXT
);

107 changes: 102 additions & 5 deletions package-lock.json

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

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
"devDependencies": {
"@cloudflare/workers-types": "^4.20240423.0",
"typescript": "^5.0.4",
"wrangler": "^3.47.0"
"wrangler": "^3.53.1"
},
"dependencies": {
"@cfworker/jwt": "^4.0.6",
"hono": "^4.2.9"
"@prisma/adapter-d1": "^5.13.0",
"@prisma/client": "^5.13.0",
"hono": "^4.2.9",
"prisma": "^5.13.0"
}
}
22 changes: 22 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
}

datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}

model Submissions {
id Int @id @default(autoincrement())
url String
state Int @default(0)
createdAt DateTime @default(now())
ip_address String?
country String?
user_agent String?
}
7 changes: 7 additions & 0 deletions src/Auth0JwtPayload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { JwtPayload } from '@cfworker/jwt';

export interface Auth0JwtPayload extends JwtPayload {
azp: string;
scope: string;
permissions: string[];
}
Loading