UNPKG

deep-package-manager

Version:
83 lines (66 loc) 1.79 kB
/** * Created by AlexanderC on 5/25/15. */ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Compiler = undefined; var _Action = require('../Microservice/Metadata/Action'); var _util = require('util'); var _path = require('path'); var _path2 = _interopRequireDefault(_path); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Compiles a microservice */ class Compiler { /** * Compile dependencies recursively * * @param {Microservice} microservice * @returns {Compiler} */ static compile(microservice) { for (let i in Compiler.compilers) { if (!Compiler.compilers.hasOwnProperty(i)) { continue; } Compiler.compilers[i].compile(microservice); } return this; } /** * @param {Object} microservice * @returns {Object} */ static buildLambdas(microservice) { let backendPath = microservice.autoload.backend; let actionsObj = microservice.resources.actions; let lambdas = { _: {} // @todo: move config somewhere... }; for (let i in actionsObj) { if (!actionsObj.hasOwnProperty(i)) { continue; } let action = actionsObj[i]; if (action.type === _Action.Action.LAMBDA) { let source = _path2.default.normalize(action.source); lambdas[action.identifier] = _path2.default.join(backendPath, source); lambdas._[action.identifier] = (0, _util._extend)({}, action.engine); lambdas._[action.identifier].forceUserIdentity = action.forceUserIdentity; } } return lambdas; } /** * Retrieve available compilers * * @returns {Function[]} */ static get compilers() { return []; } } exports.Compiler = Compiler;