Skip to content

Commit fc12cd9

Browse files
committed
add server api
1 parent 993ae07 commit fc12cd9

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

graphite-demo/server.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const express = require('express');
2+
const app = express();
3+
const port = 3000;
4+
5+
// Fake data for tasks
6+
const tasks = [
7+
{
8+
id: 1,
9+
description: 'Complete monthly financial report'
10+
},
11+
{
12+
id: 2,
13+
description: 'Plan team building activity'
14+
},
15+
{
16+
id: 3,
17+
description: 'Update project documentation'
18+
}
19+
];
20+
21+
app.get('/search', (req, res) => {
22+
// Retrieve the query parameter
23+
const query = req.query.query?.toLowerCase() || '';
24+
25+
// Filter tasks based on the query
26+
const filteredTasks = tasks.filter(task => task.description.toLowerCase().includes(query));
27+
28+
res.json(filteredTasks);
29+
});
30+
31+
app.listen(port, () => {
32+
console.log(`Server running on port ${port}`);
33+
});

0 commit comments

Comments
 (0)