-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathroutes.js
59 lines (52 loc) · 1.61 KB
/
routes.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
const express = require('express')
const catalogues = require('catalogues-library')
const router = express.Router()
/**
* Gets library service data
* @param {Object} req The request to parse
* @param {Object} res The response to send
*/
router.get('/services', async (req, res) =>
res.send(await catalogues.services(req.query.service))
)
/**
* Gets individual library service point data
* @param {Object} req The request to parse
* @param {Object} res The response to send
*/
router.get('/libraries', async (req, res) =>
res.send(await catalogues.libraries(req.query.service))
)
/**
* Gets ISBN availability information for library service points
* @param {Object} req The request to parse
* @param {Object} res The response to send
*/
router.get('/availability/:isbn', async (req, res) =>
res.send(await catalogues.availability(req.params.isbn, req.query.service))
)
/**
* Gets results from the library thing thingISBN service
* @param {Object} req The request to parse
* @param {Object} res The response to send
*/
router.get('/thingISBN', async (req, res) =>
res.send((await libThing.thingISBN(req.params.isbn)).isbns)
)
/**
* Gets results from open libraries free text search
* @param {Object} req The request to parse
* @param {Object} res The response to send
*/
router.get('/openlibrary', async (req, res) =>
res.send(await openLibrary.search(req.query.q))
)
/**
* Runs through tests for the ISBN search
* @param {Object} req The request to parse
* @param {Object} res The response to send
*/
router.get('/test', async (req, res) =>
res.send(await catalogues.testIsbnSearch())
)
module.exports = router