forked from pmndrs/jotai
-
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.
fix(website): configure Vercel serverless functions (pmndrs#1433)
* fix(website): configure Vercel serverless functions * fix(website): remove console.log * fix(website): add api dir * fix(website): remove Gatsby function path from Vercel config
- Loading branch information
Showing
5 changed files
with
282 additions
and
183 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,33 @@ | ||
import * as postmark from 'postmark'; | ||
|
||
const client = new postmark.ServerClient(process.env.POSTMARK_API_TOKEN); | ||
|
||
export default async function handler(request, response) { | ||
const body = request.body; | ||
|
||
if (!body.name || !body.email || !body.message) { | ||
return response.status(400).json({ data: 'Invalid' }); | ||
} | ||
|
||
const subject = `Message from ${body.name} (${body.email}) via jotai.org`; | ||
|
||
const message = ` | ||
Name: ${body.name}\r\n | ||
Email: ${body.email}\r\n | ||
Message: ${body.message} | ||
`; | ||
|
||
try { | ||
client.sendEmail({ | ||
From: '[email protected]', | ||
To: process.env.EMAIL_RECIPIENTS, | ||
Subject: subject, | ||
ReplyTo: body.email, | ||
TextBody: message, | ||
}); | ||
|
||
response.status(200).json({ status: 'Sent' }); | ||
} catch (error) { | ||
response.status(500).json({ status: 'Not sent' }); | ||
} | ||
} |
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
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,9 @@ | ||
{ | ||
"functions": { | ||
"api/*.js": { | ||
"memory": 128, | ||
"maxDuration": 30 | ||
} | ||
}, | ||
"trailingSlash": false | ||
} |
Oops, something went wrong.