This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const rp = require('request-promise'); | |
const cheerio = require('cheerio'); | |
const functions = require('firebase-functions'); | |
const admin = require('firebase-admin'); | |
admin.initializeApp(); | |
const db = admin.firestore(); | |
exports.allyPallyFarmersMarket = functions.https.onRequest((request, response) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run -v $PWD:/usr/app -w /usr/app -p 9005:9005 -u node -it lgvalle/firebasetools:v2 sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See list of docker virtual machines on the local box | |
$ docker-machine ls | |
NAME ACTIVE URL STATE URL SWARM DOCKER ERRORS | |
default * virtualbox Running tcp://192.168.99.100:2376 v1.9.1 | |
# Note the host URL 192.168.99.100 - it will be used later! | |
# Build an image from current folder under given image name | |
$ docker build -t gleb/demo-app . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
rethinkdb: | |
image: rethinkdb:2.3 | |
ports: | |
- "8080:8080" | |
- "28015:28015" | |
- "29015:29015" | |
restart: always | |
volumes: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ONE_HOUR = 3600000 | |
var functions = require('firebase-functions'); | |
const URL_THE_GUARDIAN = "https://www.theguardian.com/uk/london/rss" | |
var Client = require('node-rest-client').Client; | |
var client = new Client(); | |
const admin = require('firebase-admin'); | |
admin.initializeApp(functions.config().firebase); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const functions = require('firebase-functions') | |
const URL_THE_GUARDIAN = "https://www.theguardian.com/uk/london/rss" | |
const Client = require('node-rest-client').Client | |
const client = new Client() | |
exports.fetch = functions.https.onRequest((req, res) => { | |
client.get(URL_THE_GUARDIAN, function (data, response) { | |
const items = cleanUp(data) | |
res.status(201) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cleanUp(data) { | |
// Empty array to add cleaned up elements to | |
const items = [] | |
// We are only interested in children of the 'channel' element | |
const channel = data.rss.channel | |
channel.item.forEach(element => { | |
item = { | |
title: element.title, | |
description: element.description, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
"title": "'Leaving London means I can afford kids': readers on why the capital lost its sparkle", | |
"description": "Almost 100,000 Londoners moved out last year. Here they, and others who are avoiding the city altogether, explain why it is no longer the place to be<br></p><p>The rate of Londoners leaving the capital is more than <a href="https://www.theguardian.com/uk-news/2017/jul/24/bloated-london-property-prices-fuelling-exodus-from-capital">80% higher than five years ago</a>, according to Savills, with people in their thirties the age group most likely to leave. </p><p>We asked readers why they’re leaving London, or avoiding moving to the capital altogether. Here’s what you said:</p><p>All my salary was being spent on living costs in London</p> <a href="https://www.theguardian.com/uk-news/2017/jul/31/leaving-london-means-i-can-afford-kids-readers-on-why-the-capital-lost-its-sparkle">Continue reading...</a>", | |
"date": "Mon, 31 Jul 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<rss xmlns:media=”http://search.yahoo.com/mrss/" xmlns:dc=”http://purl.org/dc/elements/1.1/" version=”2.0"> | |
<channel> | |
<title>London | The Guardian</title> | |
<link>https://www.theguardian.com/uk/london</link> | |
<description>Latest news and features from theguardian.com, the world’s leading liberal voice</description> | |
<language>en-gb</language> | |
<copyright>Guardian News and Media Limited or its affiliated companies. All rights reserved. 2017</copyright> | |
<pubDate>Mon, 31 Jul 2017 15:32:49 GMT</pubDate> | |
<dc:date>2017–07–31T15:32:49Z</dc:date> | |
<dc:language>en-gb</dc:language> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Client = require('node - rest - client').Client | |
const client = new Client() | |
exports.fetch = functions.https.onRequest((req, res) => { | |
client.get(BACKEND_URL, function (data, response) { | |
(…) // TODO Clean up | |
return res.status(200) | |
.type('application / json') | |
.send(data) |
NewerOlder