@minimaltech/node-infra
Version:
Minimal Technology NodeJS Infrastructure - Loopback 4 Framework
48 lines • 2.61 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var _a, _b, _c, _d;
var RedisDataSource_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RedisDataSource = void 0;
const datasources_1 = require("../../base/datasources");
const core_1 = require("@loopback/core");
const connector_1 = require("./connector");
const options = {
connector: 'redis',
name: (_a = process.env.APP_ENV_REDIS_DATASOURCE_NAME) !== null && _a !== void 0 ? _a : 'redis',
host: (_b = process.env.APP_ENV_REDIS_DATASOURCE_HOST) !== null && _b !== void 0 ? _b : '0.0.0.0',
port: (_c = process.env.APP_ENV_REDIS_DATASOURCE_PORT) !== null && _c !== void 0 ? _c : '6379',
password: (_d = process.env.APP_ENV_REDIS_DATASOURCE_PASSWORD) !== null && _d !== void 0 ? _d : 'password',
};
let RedisDataSource = RedisDataSource_1 = class RedisDataSource extends datasources_1.BaseDataSource {
constructor(settings = options) {
super({ settings, scope: RedisDataSource_1.name });
this.connector = new connector_1.RedisConnector({ settings });
this.connector.initialize({ context: this });
this.logger.info('Redis DataSource Settings: %j', this.settings);
}
getConnector() {
return this.connector;
}
execute(command, parameters, extra) {
return this.getConnector().execute(command, parameters, extra);
}
};
exports.RedisDataSource = RedisDataSource;
RedisDataSource.dataSourceName = options.name;
exports.RedisDataSource = RedisDataSource = RedisDataSource_1 = __decorate([
__param(0, (0, core_1.inject)(`datasources.config.${options.name}`, { optional: true })),
__metadata("design:paramtypes", [Object])
], RedisDataSource);
//# sourceMappingURL=datasource.js.map