actionhero
Version:
The reusable, scalable, and quick node.js API server for stateless and stateful applications
33 lines (32 loc) • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Initializer = void 0;
/**
* Create a new Actionhero Initializer. The required properties of an initializer. These can be defined statically (this.name) or as methods which return a value.
*/
class Initializer {
constructor() {
this.name = null;
this.loadPriority = 1000;
this.startPriority = 1000;
this.stopPriority = 1000;
}
validate() {
if (!this.name) {
throw new Error("name is required for this initializer");
}
const priorities = [
"loadPriority",
"startPriority",
"stopPriority",
];
priorities.forEach((priority) => {
if (!this[priority] ||
typeof this[priority] !== "number" ||
this[priority] < 0) {
throw new Error(`${priority} is a required property for the initializer \`${this.name}\``);
}
});
}
}
exports.Initializer = Initializer;