├── package.json ├── index.js ├── .gitignore └── README.md /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node_rss_server", 3 | "version": "1.0.0", 4 | "description": "A simple server to convert RSS feed into JSON", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "node index.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "Ayush Sharma", 11 | "license": "ISC", 12 | "dependencies": { 13 | "express": "4.15.2", 14 | "rss-to-json": "1.0.2" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var app = express(); 3 | var Feed = require('rss-to-json'); 4 | 5 | app.use(function(req, res, next) { 6 | res.header("Access-Control-Allow-Origin", "*"); 7 | res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); 8 | next(); 9 | }); 10 | 11 | app.set('port', (process.env.PORT || 5000)); 12 | 13 | app.get('/', function(req, res, next) { 14 | if (req.query.feedURL) { 15 | Feed.load(req.query.feedURL, function(err, rss){ 16 | if (err) { 17 | res.send({ 'error': 'An error has occurred' }); 18 | } else { 19 | res.send(rss); 20 | } 21 | }); 22 | } else { 23 | res.status(400).send({ 'error': 'feedURL is required' }); 24 | } 25 | }); 26 | 27 | app.listen(app.get('port'), function() { 28 | console.log('Node app is running on port', app.get('port')); 29 | }); 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #### RSS to JSON 2 | 3 | A `GET` API to convert your rss feed into JSON. 4 | 5 | Special thanks to https://www.npmjs.com/package/rss-to-json 6 | 7 | Usage: 8 | 9 | ##### Request 10 | 11 | ``` 12 | Request URL: https://morning-earth-19323.herokuapp.com/?feedURL=https://medium.com/feed/@ayusharma.in 13 | Request Method:GET 14 | Status Code:200 OK 15 | Remote Address:192.168.0.104:5000 16 | ``` 17 | ##### Response 18 | ``` 19 | { 20 | "items":[ 21 | { 22 | "title":"Map, Reduce & Filter as Higher Order Functions", 23 | "description":"", 24 | "link":"https://medium.com/@ayusharma.in/map-reduce-filter-as-higher-order-functions-377937ed5163?source=rss-ffdb15785e37------2", 25 | "url":"https://medium.com/@ayusharma.in/map-reduce-filter-as-higher-order-functions-377937ed5163?source=rss-ffdb15785e37------2", 26 | "created":1493784185000 27 | }, 28 | { 29 | "title":"IIFE", 30 | "description":"", 31 | "link":"https://medium.com/@ayusharma.in/iife-11e720a0e77a?source=rss-ffdb15785e37------2", 32 | "url":"https://medium.com/@ayusharma.in/iife-11e720a0e77a?source=rss-ffdb15785e37------2", 33 | "created":1493054918000 34 | }, 35 | { 36 | "title":"CI & CD with Gitlab", 37 | "description":"", 38 | "link":"https://medium.com/@ayusharma.in/ci-cd-with-gitlab-c490e7da9a9e?source=rss-ffdb15785e37------2", 39 | "url":"https://medium.com/@ayusharma.in/ci-cd-with-gitlab-c490e7da9a9e?source=rss-ffdb15785e37------2", 40 | "created":1490454490000 41 | }, 42 | { 43 | "title":"Close a hung up terminal / Stuck after ssh", 44 | "description":"", 45 | "link":"https://medium.com/@ayusharma.in/close-a-hung-up-terminal-stuck-after-ssh-fe9546ed12a7?source=rss-ffdb15785e37------2", 46 | "url":"https://medium.com/@ayusharma.in/close-a-hung-up-terminal-stuck-after-ssh-fe9546ed12a7?source=rss-ffdb15785e37------2", 47 | "created":1482822487000 48 | }, 49 | { 50 | "title":"A Basic Introduction to Apache HBASE — 1", 51 | "description":"", 52 | "link":"https://medium.com/@ayusharma.in/a-basic-introduction-to-apache-hbase-1-7ba906a4196f?source=rss-ffdb15785e37------2", 53 | "url":"https://medium.com/@ayusharma.in/a-basic-introduction-to-apache-hbase-1-7ba906a4196f?source=rss-ffdb15785e37------2", 54 | "created":1467845049000 55 | }, 56 | { 57 | "title":"Generate PDF File using PhantomJS", 58 | "description":"", 59 | "link":"https://medium.com/@ayusharma.in/generate-pdf-file-using-phantomjs-885a374cda61?source=rss-ffdb15785e37------2", 60 | "url":"https://medium.com/@ayusharma.in/generate-pdf-file-using-phantomjs-885a374cda61?source=rss-ffdb15785e37------2", 61 | "created":1467749158000 62 | }, 63 | { 64 | "title":"Python Pyramid — Introduction", 65 | "description":"", 66 | "link":"https://medium.com/@ayusharma.in/python-pyramid-introduction-acbfb9304688?source=rss-ffdb15785e37------2", 67 | "url":"https://medium.com/@ayusharma.in/python-pyramid-introduction-acbfb9304688?source=rss-ffdb15785e37------2", 68 | "created":1455620652000 69 | }, 70 | { 71 | "title":"GULP", 72 | "description":"", 73 | "link":"https://medium.com/@ayusharma.in/using-gulp-48754261d222?source=rss-ffdb15785e37------2", 74 | "url":"https://medium.com/@ayusharma.in/using-gulp-48754261d222?source=rss-ffdb15785e37------2", 75 | "created":1455478338000 76 | }, 77 | { 78 | "title":"Basic Development Environment for Ubuntu", 79 | "description":"", 80 | "link":"https://medium.com/@ayusharma.in/basic-development-environment-for-ubuntu-9b945f6b533f?source=rss-ffdb15785e37------2", 81 | "url":"https://medium.com/@ayusharma.in/basic-development-environment-for-ubuntu-9b945f6b533f?source=rss-ffdb15785e37------2", 82 | "created":1455391187000 83 | }, 84 | { 85 | "title":"An informal meetup with Srishti, Richa, Siddhesh & Ayush.", 86 | "description":"", 87 | "link":"https://medium.com/@ayusharma.in/an-informal-meetup-with-srishti-richa-siddhesh-ayush-d5466bc8d597?source=rss-ffdb15785e37------2", 88 | "url":"https://medium.com/@ayusharma.in/an-informal-meetup-with-srishti-richa-siddhesh-ayush-d5466bc8d597?source=rss-ffdb15785e37------2", 89 | "created":1455256122000 90 | } 91 | ], 92 | "title":"Stories by Ayush on Medium", 93 | "description":"Stories by Ayush on Medium", 94 | "url":"https://medium.com/@ayusharma.in?source=rss-ffdb15785e37------2" 95 | } 96 | ``` 97 | --------------------------------------------------------------------------------