add project routes
This commit is contained in:
parent
b8596b2296
commit
d03c86ef42
1 changed files with 18 additions and 0 deletions
18
server/routes/projects.js
Normal file
18
server/routes/projects.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
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;
|
Loading…
Reference in a new issue