mirror of
https://github.com/khoaliber/dockhand.git
synced 2026-03-09 13:24:51 +00:00
Initial commit
This commit is contained in:
21
routes/api/legal/privacy/+server.ts
Normal file
21
routes/api/legal/privacy/+server.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { json, text } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
export const GET: RequestHandler = async ({ url }) => {
|
||||
try {
|
||||
const privacyPath = join(process.cwd(), 'PRIVACY.txt');
|
||||
const content = readFileSync(privacyPath, 'utf-8');
|
||||
|
||||
// Return as plain text if requested
|
||||
if (url.searchParams.get('format') === 'text') {
|
||||
return text(content);
|
||||
}
|
||||
|
||||
return json({ content });
|
||||
} catch (error) {
|
||||
console.error('Failed to read PRIVACY.txt:', error);
|
||||
return json({ error: 'Privacy policy file not found' }, { status: 404 });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user