all files / lib/ typescript-rest.ts

60% Statements 12/20
12.5% Branches 1/8
100% Functions 0/0
60% Lines 12/20
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                                 
"use strict";
 
import * as path from "path";
import * as fs from "fs-extra";
 
import * as Errors from "./server-errors";
import * as Return from "./server-return";
import {Server} from "./server";
 
export * from "./decorators";
export * from "./server-types";
export * from "./server";
 
export {Return};
export {Errors};
 
const CONFIG_FILE = path.join(process.cwd(), 'rest.config');
Iif (fs.existsSync(CONFIG_FILE)) {
    let 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);
    }
}