18 lines
532 B
JavaScript
18 lines
532 B
JavaScript
![]() |
const express = require('express');
|
||
|
const router = express.Router();
|
||
|
const fs = require('fs-extra');
|
||
|
const path = require('path');
|
||
|
|
||
|
// Get all projects
|
||
|
router.get('/', async (req, res) => {
|
||
|
try {
|
||
|
const projectsPath = path.join(__dirname, '../content/projects/projects.json');
|
||
|
const projects = await fs.readJSON(projectsPath);
|
||
|
res.json(projects);
|
||
|
} catch (error) {
|
||
|
console.error('Error fetching projects:', error);
|
||
|
res.status(500).json({ error: 'Failed to fetch projects' });
|
||
|
}
|
||
|
});
|
||
|
|
||
|
module.exports = router;
|