GithubHelp home page GithubHelp logo

diffblue's Introduction

Node.js

We would like you to provide a solution to the following task:

Implement a Node.js Express server which will provide two calls:

  1. "/storeRepoDetails".
  2. "/wordsForAuthors".

The first call will take a single parameter "repository" (either using GET or POST, the choice is up to you), which contains a link to a public http repository. The server will clone the repository on a local filesystem, and then extract information (date, author, commit message) about all the commits in the repository. This information then gets stored in a MongoDB database using Mongoose. Upon completion, the server returns a JSON file, either {"success" : true} if everything went through, or {"success" : false, "errorMessage" : "..."} with an explanatory error message in case there was a problem.

The second call will take a single parameter "author" (again using GET or POST), which contains a string representing an author of commits. The returned value will be a JSON array of strings containing all words that occur in author's commit messages. The list should not contain any repetitions.

Running Notes

To run with npm

npm start

or straight up node

node server.js

On running you can set two env vars - 'PORT' your desired port number (defaults 3000), and 'MONGODB_URI' which is a mongo db uri (defaults to localhost/diffblue). If you have no DB running locally expect it to crash on run, I have provided a URI in the comments of the code that can be used if setting up a local MongoDB is too much trouble.

Usage

As requested, you can POST to /storeRepoDetails with a URL to a public repository that you want processed as plain text body. For example

curl -X POST -H "Content-Type: text/plain" -d 'https://github.com/royletron/dungeon-advisor' "http://localhost:3000/storeRepoDetails"

Which will respond with an object of format {status: 'ok' || 'error', message: 'relevant message appears here'} for the above you should get

{"status":"ok","message":"repo pulled and saved"}

Once there is some data in the DB for repos you can then get word data for a particular commiter using a GET to /wordsForAuthors with the email of the commiter sent as a query param. For example:

curl -X GET -H "Content-Type: text/javascript" "http://localhost:3000/[email protected]"

diffblue's People

Watchers

 avatar  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.