Fix PDF and branding routes to use /api prefix
- Add /api prefix to PDF and branding route registration in server.ts - Remove /api prefix from individual route definitions - Fixes routing issue where PDF endpoints were not accessible through nginx Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
978286606d
commit
4894679357
3 changed files with 13 additions and 13 deletions
|
|
@ -20,7 +20,7 @@ const brandingSchema = z.object({
|
||||||
|
|
||||||
export async function brandingRoutes(fastify: FastifyInstance) {
|
export async function brandingRoutes(fastify: FastifyInstance) {
|
||||||
// Get all branding configurations
|
// Get all branding configurations
|
||||||
fastify.get('/api/branding', async (request, reply) => {
|
fastify.get('/', async (request, reply) => {
|
||||||
try {
|
try {
|
||||||
const brandings = brandingService.listBrandings();
|
const brandings = brandingService.listBrandings();
|
||||||
reply.send({ brandings });
|
reply.send({ brandings });
|
||||||
|
|
@ -30,7 +30,7 @@ export async function brandingRoutes(fastify: FastifyInstance) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get a specific branding configuration
|
// Get a specific branding configuration
|
||||||
fastify.get<{ Params: { id: string } }>('/api/branding/:id', async (request, reply) => {
|
fastify.get<{ Params: { id: string } }>('/:id', async (request, reply) => {
|
||||||
try {
|
try {
|
||||||
const { id } = request.params;
|
const { id } = request.params;
|
||||||
const branding = brandingService.getBranding(id);
|
const branding = brandingService.getBranding(id);
|
||||||
|
|
@ -46,7 +46,7 @@ export async function brandingRoutes(fastify: FastifyInstance) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create or update branding
|
// Create or update branding
|
||||||
fastify.post<{ Params: { id?: string } }>('/api/branding/:id?', async (request, reply) => {
|
fastify.post<{ Params: { id?: string } }>('/:id?', async (request, reply) => {
|
||||||
try {
|
try {
|
||||||
const { id } = request.params;
|
const { id } = request.params;
|
||||||
const body = brandingSchema.parse(request.body);
|
const body = brandingSchema.parse(request.body);
|
||||||
|
|
@ -66,7 +66,7 @@ export async function brandingRoutes(fastify: FastifyInstance) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Delete branding
|
// Delete branding
|
||||||
fastify.delete<{ Params: { id: string } }>('/api/branding/:id', async (request, reply) => {
|
fastify.delete<{ Params: { id: string } }>('/:id', async (request, reply) => {
|
||||||
try {
|
try {
|
||||||
const { id } = request.params;
|
const { id } = request.params;
|
||||||
|
|
||||||
|
|
@ -83,7 +83,7 @@ export async function brandingRoutes(fastify: FastifyInstance) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get default branding
|
// Get default branding
|
||||||
fastify.get('/api/branding/default', async (request, reply) => {
|
fastify.get('/default', async (request, reply) => {
|
||||||
try {
|
try {
|
||||||
const branding = brandingService.getDefaultBranding();
|
const branding = brandingService.getDefaultBranding();
|
||||||
reply.send(branding);
|
reply.send(branding);
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ const labelSchema = z.object({
|
||||||
|
|
||||||
export async function pdfRoutes(fastify: FastifyInstance) {
|
export async function pdfRoutes(fastify: FastifyInstance) {
|
||||||
// Register a custom font for PDF generation
|
// Register a custom font for PDF generation
|
||||||
fastify.post('/api/pdf/fonts/register', async (request, reply) => {
|
fastify.post('/fonts/register', async (request, reply) => {
|
||||||
try {
|
try {
|
||||||
const data = request.body as { name: string; fontData: string }; // base64 encoded font data
|
const data = request.body as { name: string; fontData: string }; // base64 encoded font data
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@ export async function pdfRoutes(fastify: FastifyInstance) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// List registered fonts
|
// List registered fonts
|
||||||
fastify.get('/api/pdf/fonts', async (request, reply) => {
|
fastify.get('/fonts', async (request, reply) => {
|
||||||
try {
|
try {
|
||||||
const fonts = pdfService.getRegisteredFonts();
|
const fonts = pdfService.getRegisteredFonts();
|
||||||
reply.send({ fonts });
|
reply.send({ fonts });
|
||||||
|
|
@ -76,7 +76,7 @@ export async function pdfRoutes(fastify: FastifyInstance) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Generate a simple text PDF
|
// Generate a simple text PDF
|
||||||
fastify.post('/api/pdf/text', async (request, reply) => {
|
fastify.post('/text', async (request, reply) => {
|
||||||
try {
|
try {
|
||||||
const body = textPDFSchema.parse(request.body)
|
const body = textPDFSchema.parse(request.body)
|
||||||
const pdf = pdfService.generateTextPDF(body.content, body.options || { width: 612, height: 792, margin: 72 })
|
const pdf = pdfService.generateTextPDF(body.content, body.options || { width: 612, height: 792, margin: 72 })
|
||||||
|
|
@ -91,7 +91,7 @@ export async function pdfRoutes(fastify: FastifyInstance) {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Generate a certificate PDF
|
// Generate a certificate PDF
|
||||||
fastify.post('/api/pdf/certificate', async (request, reply) => {
|
fastify.post('/certificate', async (request, reply) => {
|
||||||
try {
|
try {
|
||||||
const body = certificateSchema.parse(request.body)
|
const body = certificateSchema.parse(request.body)
|
||||||
const pdf = pdfService.generateCertificate(body)
|
const pdf = pdfService.generateCertificate(body)
|
||||||
|
|
@ -106,7 +106,7 @@ export async function pdfRoutes(fastify: FastifyInstance) {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Generate a label PDF
|
// Generate a label PDF
|
||||||
fastify.post('/api/pdf/label', async (request, reply) => {
|
fastify.post('/label', async (request, reply) => {
|
||||||
try {
|
try {
|
||||||
const body = labelSchema.parse(request.body)
|
const body = labelSchema.parse(request.body)
|
||||||
const pdf = pdfService.generateLabel(body)
|
const pdf = pdfService.generateLabel(body)
|
||||||
|
|
@ -121,7 +121,7 @@ export async function pdfRoutes(fastify: FastifyInstance) {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Health check for PDF service
|
// Health check for PDF service
|
||||||
fastify.get('/api/pdf/health', async (request, reply) => {
|
fastify.get('/health', async (request, reply) => {
|
||||||
reply.send({
|
reply.send({
|
||||||
status: 'ok',
|
status: 'ok',
|
||||||
service: 'tinypdf-plus',
|
service: 'tinypdf-plus',
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,8 @@ server.register(plantRoutes, { prefix: '/api/plants' });
|
||||||
// PDF generation
|
// PDF generation
|
||||||
import { pdfRoutes } from './routes/pdf.routes';
|
import { pdfRoutes } from './routes/pdf.routes';
|
||||||
import { brandingRoutes } from './routes/branding.routes';
|
import { brandingRoutes } from './routes/branding.routes';
|
||||||
server.register(pdfRoutes);
|
server.register(pdfRoutes, { prefix: '/api/pdf' });
|
||||||
server.register(brandingRoutes);
|
server.register(brandingRoutes, { prefix: '/api/branding' });
|
||||||
|
|
||||||
// Phase 10: Compliance
|
// Phase 10: Compliance
|
||||||
import { auditRoutes } from './routes/audit.routes';
|
import { auditRoutes } from './routes/audit.routes';
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue