infrastructure-components
Version:
Infrastructure-Components configure the infrastructure of your React-App as part of your React-Components.
44 lines • 1.65 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const types_1 = __importDefault(require("../types"));
const middleware_component_1 = require("../middleware/middleware-component");
const route_component_1 = require("../route/route-component");
const libs_1 = require("../libs");
exports.WEBAPP_INSTANCE_TYPE = "WebAppComponent";
/**
* identifies a component as a WebApp: it implements all the required fields
*
* @param component to be tested
*/
function isWebApp(component) {
return component !== undefined &&
component.instanceType === exports.WEBAPP_INSTANCE_TYPE;
}
exports.isWebApp = isWebApp;
/**
* The WebApp is a client that runs in the browser, SPA or SSR
*
* @param props
*/
exports.default = (props) => {
//console.log ("webapp: ", props);
// the WebAppComponent must have all the properties of IClient
const clientProps = {
infrastructureType: types_1.default.INFRASTRUCTURE_TYPE_CLIENT,
instanceType: exports.WEBAPP_INSTANCE_TYPE,
instanceId: props.id
};
const webappProps = {
middlewares: libs_1.getChildrenArray(props.children)
.filter(child => middleware_component_1.isMiddleware(child)),
routes: libs_1.getChildrenArray(props.children)
.filter(child => route_component_1.isRoute(child)),
// TODO add redirects!!!!
redirects: []
};
return Object.assign(props, clientProps, webappProps);
};
//# sourceMappingURL=webapp-component.js.map