File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments