elseware-nodejs 1.7.9 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1 +1 @@
1
- # elseware-nodejs
1
+ # elseware-nodejs
package/dist/index.cjs CHANGED
@@ -347,20 +347,29 @@ function loadEnv(options) {
347
347
  return options.transform ? options.transform(result.data) : result.data;
348
348
  }
349
349
  function handleError(error) {
350
- logger.danger("ENV VALIDATION FAILED");
350
+ logger.danger("Env validation failed");
351
351
  const grouped = {};
352
352
  error.issues.forEach((err) => {
353
353
  const key = err.path.join(".") || "unknown";
354
+ const rawValue = key !== "unknown" ? process.env[key] : void 0;
355
+ const isSecret = key.toLowerCase().includes("secret");
356
+ const safeValue = isSecret ? "***" : rawValue;
357
+ const messageParts = [
358
+ `message: ${err.message}`,
359
+ `code: ${err.code}`,
360
+ rawValue !== void 0 ? `value: ${JSON.stringify(safeValue)}` : null
361
+ ].filter(Boolean);
362
+ const fullMessage = messageParts.join(" | ");
354
363
  if (!grouped[key]) grouped[key] = [];
355
- grouped[key].push(err.message);
364
+ grouped[key].push(fullMessage);
356
365
  });
357
366
  Object.entries(grouped).forEach(([key, messages]) => {
358
367
  logger.info(`${key}`);
359
368
  messages.forEach((msg) => {
360
- logger.log(`${msg}`);
369
+ logger.log(` - ${msg}`);
361
370
  });
362
371
  });
363
- logger.danger("Application startup aborted.\n");
372
+ logger.danger("Application startup aborted!");
364
373
  process.exit(1);
365
374
  }
366
375
 
@@ -5167,6 +5176,84 @@ var validate = (schema) => (req, _res, next) => {
5167
5176
  }
5168
5177
  next();
5169
5178
  };
5179
+
5180
+ // src/repositories/mongo.repository.ts
5181
+ var BaseMongoRepository = class {
5182
+ model;
5183
+ constructor(model) {
5184
+ this.model = model;
5185
+ }
5186
+ async findAll(filter = {}, options = {}) {
5187
+ let query = this.model.find(filter);
5188
+ if (options.select) query = query.select(options.select);
5189
+ if (options.sort) query = query.sort(options.sort);
5190
+ if (options.limit) query = query.limit(options.limit);
5191
+ if (options.skip) query = query.skip(options.skip);
5192
+ return query.exec();
5193
+ }
5194
+ async findById(id) {
5195
+ return this.model.findById(id).exec();
5196
+ }
5197
+ async findOne(filter) {
5198
+ return this.model.findOne(filter).exec();
5199
+ }
5200
+ async create(data) {
5201
+ return this.model.create(data);
5202
+ }
5203
+ async updateById(id, data) {
5204
+ return this.model.findByIdAndUpdate(id, data, {
5205
+ new: true,
5206
+ runValidators: true
5207
+ }).exec();
5208
+ }
5209
+ async deleteById(id) {
5210
+ return this.model.findByIdAndDelete(id).exec();
5211
+ }
5212
+ };
5213
+
5214
+ // src/repositories/postgres.repository.ts
5215
+ var BasePostgresRepository = class {
5216
+ model;
5217
+ // prisma model (e.g. prisma.testPost)
5218
+ constructor(model) {
5219
+ this.model = model;
5220
+ }
5221
+ async findAll(filter = {}, options = {}) {
5222
+ return this.model.findMany({
5223
+ where: filter,
5224
+ select: options.select,
5225
+ orderBy: options.sort,
5226
+ take: options.limit,
5227
+ skip: options.skip
5228
+ });
5229
+ }
5230
+ async findById(id) {
5231
+ return this.model.findUnique({
5232
+ where: { id }
5233
+ });
5234
+ }
5235
+ async findOne(filter) {
5236
+ return this.model.findFirst({
5237
+ where: filter
5238
+ });
5239
+ }
5240
+ async create(data) {
5241
+ return this.model.create({
5242
+ data
5243
+ });
5244
+ }
5245
+ async updateById(id, data) {
5246
+ return this.model.update({
5247
+ where: { id },
5248
+ data
5249
+ });
5250
+ }
5251
+ async deleteById(id) {
5252
+ return this.model.delete({
5253
+ where: { id }
5254
+ });
5255
+ }
5256
+ };
5170
5257
  var AzureBlobStorageService = class {
5171
5258
  containerName;
5172
5259
  blobServiceClient;
@@ -5628,6 +5715,8 @@ exports.AppError = AppError;
5628
5715
  exports.AzureBlobStorageService = AzureBlobStorageService;
5629
5716
  exports.BPlusTree = BPlusTree;
5630
5717
  exports.BTree = BTree;
5718
+ exports.BaseMongoRepository = BaseMongoRepository;
5719
+ exports.BasePostgresRepository = BasePostgresRepository;
5631
5720
  exports.BinaryHeap = BinaryHeap;
5632
5721
  exports.BinarySearchTree = BinarySearchTree;
5633
5722
  exports.BinaryTree = BinaryTree;