forked from dvajs/dva
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxy.config.js
79 lines (74 loc) · 1.3 KB
/
proxy.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'use strict';
const friends = [
{
id: 1,
name: 'Bruce Wayne',
username: '@Batman'
},
{
id: 2,
name: 'Clark Kent',
username: '@Superman'
},
{
id: 3,
name: 'Maz ‘Magnus’ Eisenhardt',
username: '@Magneto'
},
{
id: 4,
name: 'Reed Richards',
username: '@Mister-Fantastic'
},
{
id: 5,
name: 'Charles Francis Xavier',
username: '@ProfessorX'
},
{
id: 6,
name: 'Lex Luthor',
username: '@LexLuthor'
},
{
id: 7,
name: 'Benjamin Grimm',
username: '@Thing'
},
{
id: 8,
name: 'Walter Langkowski',
username: '@Sasquatch'
},
{
id: 9,
name: 'Andrew Nolan',
username: '@Ferro-Lad'
},
{
id: 10,
name: 'Jonathan Osterman',
username: '@Dr.Manhattan'
}
];
module.exports = {
'/api/search': function (req, res) {
setTimeout(function() {
const query = req.query.q;
const results = friends.filter(friend => {
let keep = false;
Object.keys(friend).forEach(key => {
const val = friend[key].toString();
if (val.toLowerCase().includes(query.toLowerCase())) {
keep = true;
}
});
return keep;
});
res.json({
success: true,
data: results,
});
}, 600);
},
};