Giter VIP home page Giter VIP logo

snapsearch-client-node-heroku-demo's Introduction

SnapSearch-Client-Node-Heroku-Demo

This repository shows a simple Express application deployed with SnapSearch-Client-Node as an intercetor middleware.

Heroku like other PAAS systems are behind a reverse proxy, which means certain flags needs to be turned true for SnapSearch to work. These flags allow SnapSearch-Client-Node to acquire the original hostnames, ports and protocol that was used between the client and the reverse proxy.

See the index.js for the example source code.

The below shell snippet shows how to deploy this on your own Heroku. Note the usage of environment variables to pass the SnapSearch API credentials.

# clone the project
git clone https://github.com/SnapSearch/SnapSearch-Client-Node-Heroku-Demo.git

# get into the project's directory
cd SnapSearch-Client-Node-Heroku-Demo

# optional, run it locally
SNAPEMAIL=XXXX SNAPKEY=XXXX node index.js

# get heroku CLI and login
heroku login

# create a unique snapsearch demo application, where X is your unique random string
heroku create snapsearch-demo-X

# set your SnapSearch API Email and Key (you need to sign up on heroku) for this app
heroku config:set SNAPEMAIL=XXXX SNAPKEY=XXXX

# deploy on heroku 
git push heroku master

# visit the app with a non-robot-like useragent, you will not see the fully evaluated JS content
curl -A "Meh" https://snapsearch-demo-X.herokuapp.com/

# visit the app with a robot-like useragent, triggering the scrape, you'll see the fully evaluated JS content
curl -A "Googlebot" https://snapsearch-demo-X.herokuapp.com/

# compare the difference between the output!

# check the logs
heroku logs

Special Features of this Demo:

  • Shows how to make the compression middleware work with SnapSearch!
  • Shows how to deal with non-html resources such as sitemaps!
  • Shows how to make it work in Heroku!

snapsearch-client-node-heroku-demo's People

Contributors

cmcdragonkai avatar

Watchers

martin. avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.