Add CMS features with admin interface and OAuth authentication integration
- Introduced Caddy server for serving frontend and API backend. - Implemented admin dashboard for creating, editing, and managing events. - Replaced session-based authentication with token-based OAuth using Gitea. - Added support for drag-and-drop event reordering in the admin interface. - Standardized Fastify route validation with JSON schemas. - Enhanced authentication flow with cookie-based state and secure token storage. - Reworked backend routes to handle publishing, event management, and content updates. - Updated `Dockerfile.caddy` and `fly.toml` for deployment configuration.
This commit is contained in:
@ -4,9 +4,14 @@ import { db } from '../config/database.js';
|
||||
import { siteSettings } from '../db/schema.js';
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
const settingSchema = z.object({
|
||||
value: z.string(),
|
||||
});
|
||||
// Fastify JSON schema for settings body
|
||||
const settingBodyJsonSchema = {
|
||||
type: 'object',
|
||||
required: ['value'],
|
||||
properties: {
|
||||
value: { type: 'string' },
|
||||
},
|
||||
} as const;
|
||||
|
||||
const settingsRoute: FastifyPluginAsync = async (fastify) => {
|
||||
|
||||
@ -50,12 +55,12 @@ const settingsRoute: FastifyPluginAsync = async (fastify) => {
|
||||
// Update setting
|
||||
fastify.put('/settings/:key', {
|
||||
schema: {
|
||||
body: settingSchema,
|
||||
body: settingBodyJsonSchema,
|
||||
},
|
||||
preHandler: [fastify.authenticate],
|
||||
}, async (request, reply) => {
|
||||
const { key } = request.params as { key: string };
|
||||
const { value } = request.body as z.infer<typeof settingSchema>;
|
||||
const { value } = request.body as any;
|
||||
|
||||
// Check if setting exists
|
||||
const [existing] = await db
|
||||
|
||||
Reference in New Issue
Block a user