# all files / api/ get-path.js

100% Statements 18/18
100% Branches 6/6
100% Functions 2/2
100% Lines 6/6
1 branch Ignored

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22

    1

    5

    5
    5

    5

     'use strict';

    // Constants:
    import { config } from '../config';
    import constants from '../constants';

    // Utilities:
    import { join } from 'path';

    export default { handler };

    function handler (request, response) {
        let { type } = request.params;
        let extension = constants.EXTENSIONS[type];

        let { path, name } = request.query;
        let fileName = name + extension;
        path = path || join(process.cwd(), config.testDirectory, type, fileName);

        response.send({ path });
    }