├── .gitignore ├── README.md ├── app.json ├── package.json └── server.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Meidum RSS to JSON 2 | 3 | [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) 4 | 5 | A simple Heroku-ready Hapi.js app that converts a Medium RSS feed to JSON. 6 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Medium RSS to JSON", 3 | "description": "A simple Heroku-ready Hapi.js app that converts a Medium RSS feed to JSON.", 4 | "repository": "https://github.com/sanctuarycomputer/medium-rss-to-json.git", 5 | "env": { 6 | "MEDIUM_FEED_NAME": { 7 | "description": "Your user handle (include @) or publication name, more info here: https://help.medium.com/hc/en-us/articles/214874118-RSS-feeds" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "medium-rss-to-json", 3 | "version": "1.0.0", 4 | "description": "A simple Heroku-ready Hapi.js app that converts a Medium RSS feed to JSON.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/sanctuarycomputer/medium-rss-to-json.git" 12 | }, 13 | "author": "Sebastian Odell", 14 | "license": "MIT", 15 | "bugs": { 16 | "url": "https://github.com/sanctuarycomputer/medium-rss-to-json/issues" 17 | }, 18 | "homepage": "https://github.com/sanctuarycomputer/medium-rss-to-json#readme", 19 | "dependencies": { 20 | "hapi": "^16.4.1", 21 | "wreck": "^12.2.2", 22 | "xml2json": "^0.11.0" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Hapi = require('hapi'); 4 | const Wreck = require('wreck'); 5 | const Parser = require('xml2json'); 6 | const server = new Hapi.Server(); 7 | 8 | const defaultFeedName = 'sanctuary-computer-inc'; 9 | const xmlEndpoint = `https://medium.com/feed/${process.env.MEDIUM_FEED_NAME || defaultFeedName}`; 10 | 11 | server.connection({ 12 | port: (process.env.PORT || 4134), 13 | host: '0.0.0.0', 14 | routes: { cors: true } 15 | }); 16 | 17 | server.route({ 18 | method: 'GET', 19 | path: '/', 20 | handler: function (request, reply) { 21 | Wreck.get(xmlEndpoint, (err, res, payload) => { 22 | if (err) return reply(`Error: ${err}`); 23 | return reply(Parser.toJson(payload, { object: true, sanitize: false })); 24 | }); 25 | } 26 | }); 27 | 28 | server.start((err) => { 29 | if (err) throw err; 30 | console.log(`~~~> Server running at: ${server.info.uri}`); 31 | }); 32 | --------------------------------------------------------------------------------