Skip to content

Instantly share code, notes, and snippets.

View Lukas-Sachse's full-sized avatar

Lukas-Sachse

View GitHub Profile
@Lukas-Sachse
Lukas-Sachse / index.js
Created May 30, 2022 14:53
Endpoint - Contact Form
// File-Location: extensions/endpoints/contact/index.js
// Url: https://YOUR_DIRECTUS_URL/contact
module.exports = (router, { services, exceptions, getSchema }) => {
const { MailService } = services;
const { ServiceUnavailableException } = exceptions;
const { verify } = require("hcaptcha");
router.post("/", async (req, res) => {
if (!req.body.token) {
@Lukas-Sachse
Lukas-Sachse / index.js
Created May 26, 2022 08:14
Hook - Send email after form submission (text only)
/* Info: Created without using the extension-sdk */
/* Location: /extensions/hooks/YOUR_HOOK_NAME/index.js */
module.exports = function registerHook(
{ action },
{ services, exceptions, logger }
) {
const { MailService } = services;
const { ServiceUnavailableException } = exceptions;
@Lukas-Sachse
Lukas-Sachse / anmeldung_angekommen.liquid
Created May 26, 2022 08:10
Hook - Send email after form submission (with template)
<!-- Location: /templates/anmeldung_angekommen.liquid -->
{% layout "base" %} {% block content %}
<p>Hallo,</p>
<p>
Die Anmeldung von <b>{{ vorname }} {{ nachname }}</b> als
<b>{{ rolle }}</b> ist bei uns angekommen.
</p>
@Lukas-Sachse
Lukas-Sachse / index.js
Created May 26, 2022 07:50
Hook - Send email after form submission (editable templates)
/* Info: Created without using the extension-sdk */
/* Info: For using editable templates i have to mimic the way directus using email templates. */
/* Location: /extensions/hooks/YOUR_HOOK_NAME/index.js */
module.exports = function registerHook(
{ action },
{ services, exceptions, logger }
) {
const { ItemsService, MailService, FilesService } = services;
const { ServiceUnavailableException } = exceptions;