Skip to content

Image Search Abstraction Layer

Rafael J. Rodriguez edited this page Jan 6, 2017 · 2 revisions

Author

@Rafase282

Created by Rafase282

Github | FreeCodeCamp | CodePen | LinkedIn | Medium Website | E-Mail

Image Search Abstraction Layer

Objective:

Build a full stack JavaScript app that successfully reverse-engineers this: https://shurli.herokuapp.com/ and deploy it to Heroku.

Note that for each Basejump, you should create a new GitHub repository and a new Heroku project. If you can't remember how to do this, revisit https://cryptic-ridge-9197.herokuapp.com/api/imagesearch/lolcats%20funny?offset=10 and browse recent search queries like this: https://cryptic-ridge-9197.herokuapp.com/api/latest/imagesearch/. Then deploy it to Heroku.

As you build your app, you should frequently commit changes to your codebase. You can do this by running git commit -am "your commit message". Note that you should replace "your commit message" with a brief summary of the changes you made to your code.

You can push these new commits to GitHub by running git push origin master, and to Heroku by running grunt --force && grunt buildcontrol:heroku.

User Stories:

  • I can get the image URLs, alt text and page urls for a set of images relating to a given search string.
  • I can paginate through the responses by adding a ?offset=2 parameter to the URL.
  • I can get a list of the most recently submitted search strings.

Links

Environment Variables

While heroku can use them as is, cloud9 needs extra work to get them from the .env file that you would create.

Notes

The Bing search api is a pain. I recommend using a npm package to handle it, there are many and I listed one of them. You will also have to sign up to get a key which I recommend using from the .env file as to not leak your key. It has a main key but it is better to create a new one that you can delete if it gets compromised, because the main one can't be changed.

Learning about Mongoose was fun. Basically you have to require it, create a scheme, turn it into a model and then youc an use it to create documents.

1- Require Mongoose and declare Schema.

var mongoose = require('mongoose');
var Schema = mongoose.Schema;

2- Create Schema

var kittySchema = mongoose.Schema({
    name: String
});

3- Turn the schema into a model, and connect to it.

var Kitten = mongoose.model('Kitten', kittySchema);
var mongouri = process.env.MONGOLAB_URI || "mongodb://" + process.env.IP + ":27017/img-sal";
mongoose.connect(mongouri);

While you can do 1 to 3 on the server like I did, the step for and any other can be done anywhere else as long as you know how to export the model.

4- Create new documents based on the model

var silence = new Kitten({ name: 'Silence' });
console.log(silence.name); // 'Silence'

How to export the model to my api.

api(app, Kitten);

then on the api file: module.exports = function(app, History) {

The search and find can be found on the documentation along with the rest of teh steps I have listed aside from exporting.

Getting Started

  1. Welcome!
  2. Contact
  3. Get Started with Free Code Camp

Front End Development Certification

  1. HTML5 and CSS
  2. Responsive Design with Bootstrap
  3. Gear up for Success
  4. jQuery
  5. Basic JavaScript
  6. Object Oriented and Functional Programming
  7. Basic Algorithm Scripting
  8. Basic Front End Development Projects
  9. Intermediate Algorithm Scripting
  10. JSON APIs and Ajax
  11. Intermediate Front End Development Projects
  12. Claim Your Front End Development Certificate

Data Visualization Certification

  1. SASS
  2. React
  3. React Projects
  4. D3
  5. Data Visualization Projects
  6. Claim Your Data Visualization Certificate

Back End Development Certification

  1. Upper Intermediate Algorithm Scripting
  2. Automated Testing and Debugging
  3. Advanced Algorithm Scripting
  4. AngularJS (Legacy Material)
  5. Git
  6. Node.js and Express.js
  7. MongoDB
  8. API Projects
  9. Dynamic Web Applications
  10. Claim Your Back End Development Certificate

Full Stack Development Certification

  1. Greefield Nonprofit Project 1
  2. Greefield Nonprofit Project 2
  3. Legacy Nonprofit Project 1
  4. Legacy Nonprofit Project 2
  5. Claim your Full Stack Development Certification

Coding Interview Preparation

  1. Whiteboard Coding Interview Training
  2. Critical Thinking Interview Training
  3. Mock Interview 1
  4. Mock Interview 2
  5. Mock Interview 3
Clone this wiki locally