"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var bunyan = require("bunyan");
exports.serializers = {
    repository: function (repository) { return repository.full_name; },
    event: function (event) {
        if (typeof event !== 'object' || !event.payload) {
            return event;
        }
        else {
            var name = event.event;
            if (event.payload && event.payload.action) {
                name = name + "." + event.payload.action;
            }
            return {
                id: event.id,
                event: name,
                repository: event.payload.repository && event.payload.repository.full_name,
                installation: event.payload.installation && event.payload.installation.id
            };
        }
    },
    installation: function (installation) {
        if (installation.account) {
            return installation.account.login;
        }
        else {
            return installation;
        }
    },
    err: bunyan.stdSerializers.err,
    req: bunyan.stdSerializers.req,
    // Same as buyan's standard serializers, but gets headers as an object
    // instead of a string.
    // https://github.com/trentm/node-bunyan/blob/fe31b83e42d9c7f784e83fdcc528a7c76e0dacae/lib/bunyan.js#L1105-L1113
    res: function (res) {
        if (!res || !res.statusCode) {
            return res;
        }
        else {
            return {
                duration: res.duration,
                statusCode: res.statusCode,
                headers: res.getHeaders()
            };
        }
    }
};
//# sourceMappingURL=serializers.js.map