zcatalyst-cli
Version:
Command Line Tool for CATALYST
42 lines (41 loc) • 2.13 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const apig_utils_1 = require("../../apig-utils");
const runtime_store_1 = __importDefault(require("../../runtime-store"));
const config_1 = require("../../util_modules/config");
const index_1 = require("../../util_modules/logger/index");
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
const compiledRules = runtime_store_1.default.get('context.apig.local.config');
if (compiledRules === null)
return;
if (typeof compiledRules === 'object') {
(0, index_1.debug)('Using cached API Gateway rules');
return compiledRules;
}
if (!config_1.apigConfig.exists()) {
(0, index_1.debug)('No API Gateway configuration found. Skipping API Gateway rules');
return;
}
if (!config_1.apigConfig.enabled()) {
runtime_store_1.default.set('context.apig.local.config', null);
(0, index_1.info)();
(0, index_1.info)('Skipping API Gateway rules as API Gateway is disabled in local');
(0, index_1.info)();
return;
}
yield apig_utils_1.apigUtils.executeHook({ prefix: 'pre', command: 'serve' });
const rulesArr = yield apig_utils_1.apigUtils.validate();
return apig_utils_1.apigUtils.compile(rulesArr);
});