'use strict'

const Endpoint = require('./endpoint')

/**
 * 
 * @extends Endpoint
 */
class InfoEndpoint extends Endpoint {

    constructor({contributors = []} = {}) {
        super({
            name: 'info'
        })

        this._contributors = contributors        
    }

    /**
     * 
     * @param {http.ClientRequest} req 
     * @param {http.ClientResponse} res 
     */
    handle(req, res) {
        super.handle(req, res)
        // TODO
        // no more hard coding
        return {
            build: {

            },
            git: {
                commit: {
                    "id": "7adb64f",
                    "time": "2016-08-17T19:30:34+0200"
                }
            }
        }
    }
}

module.exports = InfoEndpoint
@@ -17,41 +17,187 @@
 nst 
-Endpoint = require('./endpoint')%0A
+resolve = require('path').resolve%0A%0Aconst Endpoint = require('./endpoint')%0Aconst NpmInfoContributor = require(resolve('lib/endpoints/contributors/info/npm-build-info-contributor'))
 %0A/**
@@ -282,16 +282,25 @@
 ructor(%7B
+%0A        
 contribu
@@ -311,9 +311,32 @@
  = %5B
-%5D
+NpmInfoContributor%5D%0A    
 %7D = 
@@ -435,24 +435,16 @@
 ributors
-        
 %0A    %7D%0A%0A
@@ -606,94 +606,71 @@
 es)%0A
-        // TODO%0A        // no more hard coding%0A        return %7B%0A            build:
+%0A        return this._contributors.reduce((current, next) =%3E
  %7B%0A
-%0A
     
@@ -681,179 +681,146 @@
     
-%7D,%0A            git: %7B%0A                commit: %7B%0A                    %22id%22: %227adb64f%22,%0A                    %22time%22: %222016-08-17T19:30:34+0200%22%0A                %7D%0A            %7D
+const context = next.getContext()%0A            const value = next.getInfo()%0A            current%5Bcontext%5D = value%0A            return current
 %0A   
@@ -825,16 +825,17 @@
        %7D
+)
 %0A    %7D%0A%7D

use npm build info contributor by default