Giter Site home page Giter Site logo

---wibilong---'s Introduction

node-test-app

A quick Node.js test using Express 4.

Running Locally

Make sure you have Node.js

git clone [email protected]:wibidev/node-test-app.git # or clone your own fork
cd node-test-app
npm install
npm start

Instructions

This small RESTful API will make requests to an external web service: https://shibe.online/. You have to build several endpoints that returns JSON. Feel free to organize your files like it is a real API (think scalability).

You will implement a simple UI in React/Redux which allows us to visually browse API data.

GET /shibes - Page "Shibes list"

Will make a request to fetch shibes from the external API.

GET /cats - Page "Cats list"

Will make a request to fetch cats from the external API.

GET /birds - Page "Birds list"

Will make a request to fetch birds from the external API.

GET /animals - Page "Animals list"

Lists all type of animals

Querystring parameter Description Required Default value Validations
protocol Get https or http urls yes none Can only accept http or https
count Number of entries per animal type to return no 1 Must be a number, min 1, max 30
url Get full URL or image ID no true true/false

Possible JSON outputs:

Success

{
  type: 'success',
  code: 200,
  total: 1,
  data: {
    // GET shibes
    shibes: [
      { 
        // if url = false
        id: '404ae6ed024aa5f1b9001fd755abdebe87886a0e',
        // if url = true
        url: 'http://cdn.shibe.online/shibes/404ae6ed024aa5f1b9001fd755abdebe87886a0e.jpg' 
      }
    ],
    // GET /cats
    cats: [
      { 
        // if url = false
        id: '29dde01e04e1a3cf9e3aba4069cbb823fc2b4dbf',
        // if url = true
        url: 'http://cdn.shibe.online/cats/a825445d7e3d8db2d619b97065a9c26600a7ab25.jpg' 
      }
    ],
    // GET /birds
    birds: [
      { 
        // if url = false
        id: '1fba38e7a578b08895bb4d6fd39d7afff6d582c4',
        // if url = true
        url: 'http://cdn.shibe.online/birds/9d94c4c89bf669bce30e9ee32c7448800f843e78.jpg' 
      }
    ]
  }
}

Bad request

{
  type: 'badRequest',
  code: 400,
  errors: [
    { 
      param: 'protocol',
      message: ERROR_MESSAGE
    },
    { 
      param: 'count',
      message: ERROR_MESSAGE
    },
    { 
      param: 'url',
      message: ERROR_MESSAGE
    }
  ]
}

Bonus:

Make a middleware that catch and log errors

---wibilong---'s People

Watchers

James Cloos avatar yoann herlaut 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.