Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b579342
Traduccion de Js a Ts de src/database/redis/list.js
AnyaMarcanito Oct 10, 2024
8b47ee2
Cambios en tipajes de la interface
AnyaMarcanito Oct 11, 2024
ccb5649
Merge branch 'f24' into fileTranscriptionJsToTs
AnyaMarcanito Oct 11, 2024
986b47b
Agregadas lineas para deshabilitar eslint por tipaje de tipo any en l…
AnyaMarcanito Oct 11, 2024
3d0578a
Modificacion en importacion de redis
AnyaMarcanito Oct 11, 2024
6bdfbb0
Update redis package and add types for redis
AnyaMarcanito Oct 11, 2024
bbd3165
Refactorización de importación de redis y deshabilitación de eslint p…
AnyaMarcanito Oct 11, 2024
73a58cb
Modificacion de mayusculas por minusculas en nombres de funciones de …
AnyaMarcanito Oct 11, 2024
9d72b08
Refactorizar importación de Redis y ajustar tipos en list.ts
AnyaMarcanito Oct 11, 2024
44d53cf
Correcion de tipajes en las definiciones de funciones de list.ts
AnyaMarcanito Oct 11, 2024
ceda6c3
Refactorizar función de eliminación de elementos en lista Redis
AnyaMarcanito Oct 11, 2024
12e9cd9
Refactorizar tipos y funciones en list.ts de Redis
AnyaMarcanito Oct 11, 2024
b73a34b
Revertir cambios de retorno de algunas definiciones
AnyaMarcanito Oct 11, 2024
7b67d20
Refactorizar puertos de Redis en archivo de configuración
AnyaMarcanito Oct 11, 2024
218c979
Correcciones en tipados e importaciones en src/database/redis/list.ts…
AnyaMarcanito Oct 14, 2024
d96f368
Revertir cambio en el puerto usado para redis
AnyaMarcanito Oct 14, 2024
6f7f3ed
Inicializacion del clienteRedis para evitar error TypeError: module.c…
AnyaMarcanito Oct 14, 2024
54d056f
Cambio de libreria "redis" por "ioredis" con consoles adicionales par…
AnyaMarcanito Oct 14, 2024
dbdadd3
Modificacion por inicializacion aparentemente innecesaria en list.ts …
AnyaMarcanito Oct 14, 2024
3b650f1
Refactorización de list.ts para mejorar la gestión de errores y agreg…
AnyaMarcanito Oct 14, 2024
03855d8
Correcciones a list.ts usando npx eslint --fix src/database/redis/lis…
AnyaMarcanito Oct 14, 2024
8d27b81
Eliminacion de librerias de redis y definicion de interfaces para evi…
AnyaMarcanito Oct 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion install/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"progress-webpack-plugin": "1.0.16",
"prompt": "1.3.0",
"ioredis": "5.4.1",
"redis": "^4.7.0",
"rimraf": "5.0.7",
"rss": "1.2.2",
"rtlcss": "4.1.1",
Expand Down Expand Up @@ -156,7 +157,8 @@
"@apidevtools/swagger-parser": "10.1.0",
"@commitlint/cli": "19.3.0",
"@commitlint/config-angular": "19.3.0",
"@types/async": "^3.2.16",
"@types/redis": "^4.0.10",
"@types/async": "^3.2.16",
"@types/express": "^4.17.15",
"@types/lodash": "^4.14.191",
"@types/nconf": "^0.10.3",
Expand Down
273 changes: 218 additions & 55 deletions src/database/redis/list.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,220 @@
'use strict';

"use strict";
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
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 __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var helpers_1 = require("./helpers");
module.exports = function (module) {
const helpers = require('./helpers');

module.listPrepend = async function (key, value) {
if (!key) {
return;
}
await module.client.lpush(key, value);
};

module.listAppend = async function (key, value) {
if (!key) {
return;
}
await module.client.rpush(key, value);
};

module.listRemoveLast = async function (key) {
if (!key) {
return;
}
return await module.client.rpop(key);
};

module.listRemoveAll = async function (key, value) {
if (!key) {
return;
}
if (Array.isArray(value)) {
const batch = module.client.batch();
value.forEach(value => batch.lrem(key, 0, value));
await helpers.execBatch(batch);
} else {
await module.client.lrem(key, 0, value);
}
};

module.listTrim = async function (key, start, stop) {
if (!key) {
return;
}
await module.client.ltrim(key, start, stop);
};

module.getListRange = async function (key, start, stop) {
if (!key) {
return;
}
return await module.client.lrange(key, start, stop);
};

module.listLength = async function (key) {
return await module.client.llen(key);
};
module.listPrepend = function (key, value) {
return __awaiter(this, void 0, void 0, function () {
var err_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!key) {
return [2 /*return*/];
}
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, module.client.lpush(key, value)];
case 2:
_a.sent();
return [3 /*break*/, 4];
case 3:
err_1 = _a.sent();
console.error('Error in listPrepend:', err_1);
return [3 /*break*/, 4];
case 4: return [2 /*return*/];
}
});
});
};
module.listAppend = function (key, value) {
return __awaiter(this, void 0, void 0, function () {
var err_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!key) {
return [2 /*return*/];
}
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, module.client.rpush(key, value)];
case 2:
_a.sent();
return [3 /*break*/, 4];
case 3:
err_2 = _a.sent();
console.error('Error in listAppend:', err_2);
return [3 /*break*/, 4];
case 4: return [2 /*return*/];
}
});
});
};
module.listRemoveLast = function (key) {
return __awaiter(this, void 0, void 0, function () {
var err_3;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!key) {
return [2 /*return*/, null];
}
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, module.client.rpop(key)];
case 2: return [2 /*return*/, _a.sent()];
case 3:
err_3 = _a.sent();
console.error('Error in listRemoveLast:', err_3);
return [2 /*return*/, null];
case 4: return [2 /*return*/];
}
});
});
};
module.listRemoveAll = function (key, value) {
return __awaiter(this, void 0, void 0, function () {
var batch_1, err_4;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!key) {
return [2 /*return*/];
}
_a.label = 1;
case 1:
_a.trys.push([1, 6, , 7]);
if (!Array.isArray(value)) return [3 /*break*/, 3];
batch_1 = module.client.pipeline();
value.forEach(function (val) { return batch_1.lrem(key, 0, val); });
return [4 /*yield*/, (0, helpers_1.execBatch)(batch_1)];
case 2:
_a.sent();
return [3 /*break*/, 5];
case 3: return [4 /*yield*/, module.client.lrem(key, 0, value)];
case 4:
_a.sent();
_a.label = 5;
case 5: return [3 /*break*/, 7];
case 6:
err_4 = _a.sent();
console.error('Error in listRemoveAll:', err_4);
return [3 /*break*/, 7];
case 7: return [2 /*return*/];
}
});
});
};
module.listTrim = function (key, start, stop) {
return __awaiter(this, void 0, void 0, function () {
var err_5;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!key) {
return [2 /*return*/];
}
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, module.client.ltrim(key, start, stop)];
case 2:
_a.sent();
return [3 /*break*/, 4];
case 3:
err_5 = _a.sent();
console.error('Error in listTrim:', err_5);
return [3 /*break*/, 4];
case 4: return [2 /*return*/];
}
});
});
};
module.getListRange = function (key, start, stop) {
return __awaiter(this, void 0, void 0, function () {
var err_6;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!key) {
return [2 /*return*/, []];
}
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, module.client.lrange(key, start, stop)];
case 2: return [2 /*return*/, _a.sent()];
case 3:
err_6 = _a.sent();
console.error('Error in getListRange:', err_6);
return [2 /*return*/, []];
case 4: return [2 /*return*/];
}
});
});
};
module.listLength = function (key) {
return __awaiter(this, void 0, void 0, function () {
var err_7;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!key) {
return [2 /*return*/, 0];
}
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, module.client.llen(key)];
case 2: return [2 /*return*/, _a.sent()];
case 3:
err_7 = _a.sent();
console.error('Error in listLength:', err_7);
return [2 /*return*/, 0];
case 4: return [2 /*return*/];
}
});
});
};
};
Loading