initial commit
Some checks failed
deploy / build-and-deploy (push) Failing after 21s

This commit is contained in:
2025-05-18 13:16:20 +02:00
commit 60f3f8a096
148 changed files with 17900 additions and 0 deletions

30
src/middleware.ts Normal file
View File

@@ -0,0 +1,30 @@
import { sequence } from 'astro/middleware';
import crypto from 'node:crypto';
import type { MiddlewareHandler } from 'astro';
import { logger } from '@it-astro:logger';
const actionInternalServerError: MiddlewareHandler = async (context, next) => {
let response = await next();
if (response.status === 500 && context.url.pathname.startsWith('/_actions/')) {
const json = await response.json();
const errorCode = crypto
.createHash('md5')
.update(Date.now() + context.clientAddress)
.digest('hex');
logger.error(`${errorCode}: ${json.message}`);
json.message = `Interner Fehler. Bitte versuch es erneut oder kontakiere einen Administrator.\nFehler Code: ${errorCode}`;
response = new Response(JSON.stringify(json), {
status: response.status,
headers: response.headers,
statusText: response.statusText
});
}
return response;
};
export const onRequest = sequence(actionInternalServerError);