{"size": 765, "ext": "js", "max_stars_repo_path": "server/api/index.js", "max_stars_repo_name": "webber0928/testVue", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/api/index.js", "max_issues_repo_name": "webber0928/testVue", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server/api/index.js", "max_forks_repo_name": "webber0928/testVue", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.25, "max_line_length": 56, "alphanum_fraction": 0.3960784314}
'use strict';
const fetch = require('node-fetch');
const Setup = require('../../setup');

exports.register = function (server, options, next) {

    server.route({
        method: 'POST',
        path: '/',
        handler: (request, reply) => {
            const url = Setup.api + request.payload.url;

            fetch( url, {
                timeout: 1000
            })
            .then((res) => {
                return res.json();
            }).then((json) => {
                return reply(json);
            })
            .catch((err) => {
                reply({
                    message: '出包了',
                    error: err
                });
            });
        }
    });

    next();
};

exports.register.attributes = {
    name: 'api'
};
