All files typescript-rest.ts

67.86% Statements 19/28
33.33% Branches 4/12
100% Functions 1/1
67.86% Lines 19/28

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43    1x 1x   1x 1x 1x   1x 1x 1x 1x   1x 1x   1x 1x                           1x 1x 7x 7x 1x   6x        
'use strict';
 
import * as fs from 'fs-extra';
import * as path from 'path';
 
import { Server } from './server';
import * as Errors from './server-errors';
import * as Return from './server-return';
 
export * from './decorators';
export * from './server-types';
export * from './server';
export * from './passport-authenticator';
 
export { Return };
export { Errors };
 
const CONFIG_FILE = searchConfigFile();
Iif (CONFIG_FILE && fs.existsSync(CONFIG_FILE)) {
    const config = fs.readJSONSync(CONFIG_FILE);
    if (config.useIoC) {
        Server.useIoC();
    } else if (config.serviceFactory) {
        if (config.serviceFactory.indexOf('.') === 0) {
            config.serviceFactory = path.join(process.cwd(), config.serviceFactory);
        }
        const serviceFactory = require(config.serviceFactory);
        Server.registerServiceFactory(serviceFactory);
    }
}
 
function searchConfigFile() {
    let configFile = path.join(__dirname, 'rest.config');
    while (!fs.existsSync(configFile)) {
        const fileOnParent = path.normalize(path.join(path.dirname(configFile), '..', 'rest.config'));
        if (configFile === fileOnParent) {
            return null;
        }
        configFile = fileOnParent;
    }
    return configFile;
}