Md Afiq Iskandar 03fdbb5d96 Refactor Documentation API Endpoints for Environment-Specific Paths
- Updated the documentation API endpoints to dynamically set the documentation directory based on the NODE_ENV variable, improving compatibility between development and production environments.
- Enhanced error handling for file retrieval to ensure proper responses when files are not found or invalid.
- Standardized import statements for consistency across the documentation files.
2025-07-24 17:29:30 +08:00

14 lines
420 B
JavaScript

import fs from 'fs'
import path from 'path'
export default defineEventHandler(async (event) => {
let docsDir = "";
if (process.env.NODE_ENV === "development") {
docsDir = path.resolve(process.cwd(), "content/documentation");
} else {
docsDir = path.resolve(process.cwd(), "../content/documentation");
}
const files = fs.readdirSync(docsDir)
.filter(file => file.endsWith('.md'))
return files
})