We decided it's best to avoid getting in the business of make the website an API wherever possible. Folks who are really interested in this data can now `npm i electron-releases`
This commit is contained in:
Zeke Sikelianos 2017-12-20 11:43:27 -08:00 коммит произвёл Zeke Sikelianos
Родитель 8ec78cd7f7
Коммит 26ceb4be9c
3 изменённых файлов: 0 добавлений и 55 удалений

Просмотреть файл

@ -1,28 +0,0 @@
const {chain, get, set} = require('lodash')
const cleanDeep = require('clean-deep')
module.exports = (req, res) => {
let releases = req.context.releases
if (req.query.pick) {
const props = chain(req.query.pick)
.split(',')
.map(prop => prop.trim())
.compact()
.value()
const liteReleases = releases.map(release => {
const lite = {}
props.forEach(prop => {
if (get(release, prop) !== null) {
set(lite, prop, get(release, prop))
}
})
return cleanDeep(lite)
})
return res.json(liteReleases)
}
res.json(releases)
}

Просмотреть файл

@ -80,7 +80,6 @@ app.get('/languages', routes.languages.index)
app.get('/maintainers/join', (req, res) => res.redirect('https://goo.gl/FJmZZm'))
app.get('/pulls', (req, res) => res.redirect(301, 'https://github.com/electron/electronjs.org/pulls'))
app.get('/releases', routes.releases.index)
app.get('/releases.json', routes.releases.feed)
app.get('/spectron', routes.spectron)
app.get('/userland', routes.userland.index)
app.get('/userland/*', routes.userland.show)

Просмотреть файл

@ -203,32 +203,6 @@ describe('electronjs.org', () => {
res.statusCode.should.be.equal(301)
res.headers.location.should.equal('/releases')
})
test('/releases.json', async () => {
const res = await supertest(app).get('/releases.json')
const releases = res.body
releases.should.be.an('array')
releases.length.should.be.above(270)
releases.every(release => release.version && release.version.length).should.eq(true)
// includes version data for v8, node, chromium, etc
releases.filter(release => release.deps).length.should.be.above(135)
})
test('/releases.json (lite version)', async () => {
const res = await supertest(app).get('/releases.json?pick=tag_name,published_at, deps.node')
const releases = res.body
releases.should.be.an('array')
releases.length.should.be.above(270)
releases.some(release => Object.keys(release).length === 3).should.eq(true)
const release = releases.find(release => release.tag_name === 'v1.8.1')
release.should.deep.equal({
tag_name: 'v1.8.1',
published_at: '2017-09-29T00:24:31Z',
deps: {node: '8.2.1'}
})
})
})
describe('userland', () => {