-
Notifications
You must be signed in to change notification settings - Fork 1
/
search.js
32 lines (29 loc) · 781 Bytes
/
search.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
'use strict'
const { authHeaderSchema, searchBreedQuerySchema } = require('../schemas')
async function searchBreeds (server, options) {
server.route({
url: '/search-breeds',
method: 'GET',
schema: {
query: searchBreedQuerySchema,
headers: authHeaderSchema
},
handler: async (request, response) => {
options.hdb.request({
operation: {
operation: 'search_by_value',
schema: 'dev',
table: 'breeds',
search_attribute: 'country',
search_value: request.query.country,
get_attributes: ['*']
},
headers: {
authorization: `Bearer ${request.headers['x-hdb-authorization']}`
},
response
})
}
})
}
module.exports = searchBreeds