GithubHelp home page GithubHelp logo

hatchways_backend_assessment's Introduction

Hatchways-Backend-Challenge

This project adds additional functionalities to a third party API:

 https://api.hatchways.io/assessment/blog/posts

All added features are built with Node.js and Express.js (Mocha and Chai.js for testing).

General Idea

The third party API is supposed to return a list of JSON blog posts when triggered with an HTTP GET request. However, in order to achieve that, a one valued tag query field needs to be added to the query string:

https://api.hatchways.io/assessment/blog/posts$tag=history

Added Features

1- Our task is to add functionality to search with two tag values (one at least)

http://localhost:5000/api/posts?tags=history,tech

The above URL will trigger the 3rd party API and call it twice to fetch all posts with tags: history and tech.

A simple JSON return looks as follows:

{
     "posts": [
        {
            "author": "Rylee Paul",
            "authorId": 9,
            "id": 1,
            "likes": 960,
            "popularity": 0.13,
            "reads": 50361,
            "tags": [
                "tech",
                "health"
            ]
        },
        {
            "author": "Zackery Turner",
            "authorId": 12,
            "id": 2,
            "likes": 469,
            "popularity": 0.68,
            "reads": 90406,
            "tags": [
                "startups",
                "tech",
                "history"
            ]
        },
        ....
    ]
},

2- Since some posts may have multiple tags, we might end up with many duplicattions. A filteration method needs to be implemented.

3- We need to sort the posts based on a specific sorting criteria (usually a post property of a number type)

Now our route will look like this:

http://localhost:5000/api/posts?tags=history,tech&sortBy=popularity

This will return posts ordered by the number of their popularity values and in ascending order by default.

4- Sorting needs a direction (ascending by default and descending when specified).

http://localhost:5000/api/posts?tags=history,tech&sortBy=popularity&direction=desc

Available Scripts

In the project directory, you can run:

npm start

Runs the app in the development mode.
Open http://localhost:5000/api to view it in the browser.

1- PING route:

Go to: http://localhost:5000/api/ping

2- Posts route:

Go to: http://localhost:5000/api/posts?tags=history,tech&sortBy=popularity&direction=desc

npm test

Run npm test on your terminal and check the 9 tests included in: tests/posts.js

hatchways_backend_assessment's People

Contributors

zoug86 avatar

Watchers

James Cloos 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.