File tree 5 files changed +24
-4
lines changed
5 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ title: Urgent Contact
5
5
6
6
If you have an access token then you can send me an urgent message using this form:
7
7
8
- <form id =" contact-form " method =" post " action =" /api/contact-urgent " >
8
+ <form id =" contact-form " method =" post " action =" /api/form/ contact-urgent " >
9
9
<fieldset style =" display :none " >
10
10
<label for="name">Leave blank if you're human:</label>
11
11
<input type="text" name="name" id="name" placeholder="Leave blank if you're human">
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ title: Contact
5
5
6
6
If you'd like to get in touch then you can contact me using the below form.
7
7
8
- <form id =" contact-form " method =" post " action =" /api/contact " >
8
+ <form id =" contact-form " method =" post " action =" /api/form/ contact " >
9
9
<fieldset style =" display :none " >
10
10
<label for="name">Leave blank if you're human:</label>
11
11
<input type="text" name="name" id="name" placeholder="Leave blank if you're human">
Original file line number Diff line number Diff line change 1
- import { handleForm } from "../../functions-src/forms.js"
1
+ import { handleForm } from "../../../ functions-src/forms.js"
2
2
3
3
export async function onRequest ( context ) {
4
4
if ( context . request . method !== "POST" ) {
Original file line number Diff line number Diff line change 1
- import { handleForm } from "../../functions-src/forms.js"
1
+ import { handleForm } from "../../../ functions-src/forms.js"
2
2
3
3
export async function onRequest ( context ) {
4
4
if ( context . request . method !== "POST" ) {
Original file line number Diff line number Diff line change
1
+ export async function onRequest ( context ) {
2
+ if ( context . request . method !== "GET" ) {
3
+ return new Response ( "Invalid request method" , { status : 405 } ) ;
4
+ }
5
+
6
+ const submissions = await context . env . DB_FORMS . prepare ( "SELECT * FROM submissions WHERE submitted_ts > ?" )
7
+ . bind (
8
+ new Date ( ) . subtractDays ( 30 ) . toISOString ( ) ,
9
+ )
10
+ . all ( ) ;
11
+
12
+ return Response . json ( submissions ) ;
13
+ }
14
+
15
+ // TODO: this is bad practice, consider replacing (see https://www.reddit.com/r/learnjavascript/comments/qgtut6/comment/hi8jg6w/)
16
+ Date . prototype . subtractDays = function ( days ) {
17
+ var date = new Date ( this . valueOf ( ) ) ;
18
+ date . setDate ( date . getDate ( ) - days ) ;
19
+ return date ;
20
+ }
You can’t perform that action at this time.
0 commit comments