add album api & unit test, improve document

This commit is contained in:
binaryify
2017-04-05 09:50:28 +08:00
parent f6b9ff2441
commit 6630fa1e14
9 changed files with 67 additions and 9 deletions
+18
View File
@@ -0,0 +1,18 @@
const express = require("express")
const router = express()
const { createRequest } = require("../util/util")
router.get("/", (req, res) => {
const id = req.query.id
createRequest(`/api/album/${id}`, 'GET', null)
.then(result => {
res.setHeader("Content-Type", "application/json")
res.send(result)
})
.catch(err => {
res.status(502).send('fetch error')
})
})
module.exports = router
+3 -1
View File
@@ -6,7 +6,9 @@ router.get("/", (req, res) => {
const keywords = req.query.keywords
const type = req.query.type || 1
const limit = req.query.limit || 30
const data = 's=' + keywords + '&limit=' + limit + '&type=' + type + '&offset=0'
const offset = req.query.offset || 0
const data = 's=' + keywords + '&limit=' + limit + '&type=' + type + '&offset=' + offset
createRequest('/api/search/pc/', 'POST', data)
.then(result => {
res.setHeader("Content-Type", "application/json")