From 26ceb4be9c10e7bf274f444f702e576f6d50d93f Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Wed, 20 Dec 2017 11:43:27 -0800 Subject: [PATCH] remove releases.json endpoint 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` --- routes/releases/feed.js | 28 ---------------------------- server.js | 1 - test/index.js | 26 -------------------------- 3 files changed, 55 deletions(-) delete mode 100644 routes/releases/feed.js diff --git a/routes/releases/feed.js b/routes/releases/feed.js deleted file mode 100644 index 05dd639a1..000000000 --- a/routes/releases/feed.js +++ /dev/null @@ -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) -} diff --git a/server.js b/server.js index b327b8d07..3893081b6 100644 --- a/server.js +++ b/server.js @@ -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) diff --git a/test/index.js b/test/index.js index 126a4b0db..0b094f350 100644 --- a/test/index.js +++ b/test/index.js @@ -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', () => {