-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use submit endpoint when authorised (#22)
* Use submit endpoint when authorised * Added prisma * Deploy from branch * Null check on member before accessing * Improved handling for no token * Fallback to non-secure endpoint on failure * Remove unused variable * Corrected log message * Fixed syntax * Read body once * Carry over auth header * log some of auth header * Change header name * Fix body on secure submit * Add accept header * add user-agent * Added Host header * Fix typo in header --------- Co-authored-by: Jon Breen <[email protected]>
- Loading branch information
1 parent
82afd4c
commit a65dee0
Showing
9 changed files
with
260 additions
and
75 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,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 |
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 |
---|---|---|
@@ -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 | ||
); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -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? | ||
} |
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 @@ | ||
import { JwtPayload } from '@cfworker/jwt'; | ||
|
||
export interface Auth0JwtPayload extends JwtPayload { | ||
azp: string; | ||
scope: string; | ||
permissions: string[]; | ||
} |
Oops, something went wrong.