-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d2acc73
commit c3203f0
Showing
1,719 changed files
with
297,753 additions
and
27,022 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,36 @@ | ||
// api/form-validation.js | ||
|
||
const express = require('express'); | ||
const { Resend } = require('resend'); | ||
|
||
const router = express.Router(); | ||
|
||
router.post('/', async (req, res) => { | ||
const { name, email, content } = req.body; | ||
|
||
// Initialize Resend client | ||
const resend = new Resend(process.env.EMAIL_KEY); | ||
|
||
try { | ||
// Send email using Resend | ||
const { data, error } = await resend.emails.send({ | ||
from: 'Acme <[email protected]>', | ||
to: ['[email protected]'], | ||
subject: 'Hello World', | ||
html: '<strong>It works!</strong>', | ||
}); | ||
|
||
if (error) { | ||
console.error({ error }); | ||
return res.status(500).json({ error: 'Failed to send email' }); | ||
} | ||
|
||
console.log({ data }); | ||
res.status(200).json({ message: 'Email sent successfully' }); | ||
} catch (error) { | ||
console.error(error); | ||
res.status(500).json({ error: 'Internal server error' }); | ||
} | ||
}); | ||
|
||
module.exports = router; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// api/server.js | ||
|
||
const express = require('express'); | ||
const bodyParser = require('body-parser'); | ||
const formValidationRouter = require('./form-validation'); | ||
|
||
const app = express(); | ||
const PORT = process.env.PORT || 3000; | ||
|
||
// Middleware | ||
app.use(bodyParser.urlencoded({ extended: false })); | ||
app.use(bodyParser.json()); | ||
|
||
// Routes | ||
app.use('/api/form-validation', formValidationRouter); | ||
|
||
// Serve the index.html file for the root URL | ||
app.get('/', (req, res) => { | ||
res.sendFile(path.join(__dirname, '..', 'index.html')); | ||
}); | ||
|
||
// Start server | ||
app.listen(PORT, () => { | ||
console.log(`Server is running on port ${PORT}`); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.