elseware-nodejs 1.7.10 → 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 +1 -1
- package/dist/index.cjs +80 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -2
- package/dist/index.d.ts +43 -2
- package/dist/index.js +79 -1
- package/dist/index.js.map +1 -1
- package/package.json +76 -76
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as express from 'express';
|
|
2
2
|
import { Request, Response, NextFunction } from 'express';
|
|
3
|
-
import { Model, PopulateOptions, Query } from 'mongoose';
|
|
3
|
+
import { Model, PopulateOptions, Query, UpdateQuery } from 'mongoose';
|
|
4
4
|
import { ZodTypeAny, infer } from 'zod';
|
|
5
5
|
import { CorsOptions } from 'cors';
|
|
6
6
|
import { Schema } from 'joi';
|
|
@@ -1826,6 +1826,47 @@ declare const GlobalErrorHandler: (isProd?: boolean) => (err: unknown, _req: Req
|
|
|
1826
1826
|
|
|
1827
1827
|
declare const validate: (schema: Schema) => (req: Request, _res: Response, next: NextFunction) => void;
|
|
1828
1828
|
|
|
1829
|
+
interface IRepository<T> {
|
|
1830
|
+
findAll(filter?: any, options?: any): Promise<T[]>;
|
|
1831
|
+
findById(id: string): Promise<T | null>;
|
|
1832
|
+
findOne(filter: any): Promise<T | null>;
|
|
1833
|
+
create(data: Partial<T>): Promise<T>;
|
|
1834
|
+
updateById(id: string, data: Partial<T>): Promise<T | null>;
|
|
1835
|
+
deleteById(id: string): Promise<T | null>;
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
declare class BaseMongoRepository<T> implements IRepository<T> {
|
|
1839
|
+
protected model: Model<T>;
|
|
1840
|
+
constructor(model: Model<T>);
|
|
1841
|
+
findAll(filter?: Record<string, any>, options?: {
|
|
1842
|
+
select?: string;
|
|
1843
|
+
sort?: any;
|
|
1844
|
+
limit?: number;
|
|
1845
|
+
skip?: number;
|
|
1846
|
+
}): Promise<T[]>;
|
|
1847
|
+
findById(id: string): Promise<T | null>;
|
|
1848
|
+
findOne(filter: Record<string, any>): Promise<T | null>;
|
|
1849
|
+
create(data: Partial<T>): Promise<T>;
|
|
1850
|
+
updateById(id: string, data: UpdateQuery<T>): Promise<T | null>;
|
|
1851
|
+
deleteById(id: string): Promise<T | null>;
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
declare class BasePostgresRepository<T> implements IRepository<T> {
|
|
1855
|
+
protected model: any;
|
|
1856
|
+
constructor(model: any);
|
|
1857
|
+
findAll(filter?: Record<string, any>, options?: {
|
|
1858
|
+
select?: any;
|
|
1859
|
+
sort?: any;
|
|
1860
|
+
limit?: number;
|
|
1861
|
+
skip?: number;
|
|
1862
|
+
}): Promise<T[]>;
|
|
1863
|
+
findById(id: string): Promise<T | null>;
|
|
1864
|
+
findOne(filter: Record<string, any>): Promise<T | null>;
|
|
1865
|
+
create(data: Partial<T>): Promise<T>;
|
|
1866
|
+
updateById(id: string, data: Partial<T>): Promise<T | null>;
|
|
1867
|
+
deleteById(id: string): Promise<T | null>;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1829
1870
|
interface AzureBlobStorageConfig {
|
|
1830
1871
|
connectionString: string;
|
|
1831
1872
|
accountName: string;
|
|
@@ -1972,4 +2013,4 @@ declare function toMinutes(ms: number): number;
|
|
|
1972
2013
|
declare function toHours(ms: number): number;
|
|
1973
2014
|
declare function sleep(ms: number): Promise<void>;
|
|
1974
2015
|
|
|
1975
|
-
export { APIFactory, APIFeatures, APIResponse, AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, type AllowedOriginsOptions, AppError, type AzureBlobStorageConfig, AzureBlobStorageService, BPlusTree, BTree, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, type CloudinaryConfig, CloudinaryService, ConsistentHash, CountMinSketch, type DatabaseConfig, Deque, type DirectedEdge, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, type Edge, type EmailProvider, EmailService, FenwickTree, FibNode, FibonacciHeap, GlobalErrorHandler, Graph, HashMap, HashSet, HyperLogLog, type Interval, IntervalTree, JWTService, type JWTServiceOptions, KDTree, LFUCache, LRUCache, type LoggerOptions, MaxHeap, MaxStack, MinHeap, MinStack, MulterFileHandlerService, MultiSet, Node, OrderedSet, PairingHeap, PairingNode, type Point, type Point2D, PriorityQueue, type ProgressCallback, QuadTree, Queue, RadixTree, type Rect, RedBlackTree, SMTPProvider, SegmentTree, type SendEmailOptions, Set, SinglyLinkedList, SparseTable, SplayTree, Stack, StaticArray, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, TreeNode, Trie, type UploadOptions, asyncHandler, authMiddleware, connectMongoDB, createAllowedOrigins, createCorsOptions, days, errorToString, hours, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
|
|
2016
|
+
export { APIFactory, APIFeatures, APIResponse, AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, type AllowedOriginsOptions, AppError, type AzureBlobStorageConfig, AzureBlobStorageService, BPlusTree, BTree, BaseMongoRepository, BasePostgresRepository, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, type CloudinaryConfig, CloudinaryService, ConsistentHash, CountMinSketch, type DatabaseConfig, Deque, type DirectedEdge, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, type Edge, type EmailProvider, EmailService, FenwickTree, FibNode, FibonacciHeap, GlobalErrorHandler, Graph, HashMap, HashSet, HyperLogLog, type IRepository, type Interval, IntervalTree, JWTService, type JWTServiceOptions, KDTree, LFUCache, LRUCache, type LoggerOptions, MaxHeap, MaxStack, MinHeap, MinStack, MulterFileHandlerService, MultiSet, Node, OrderedSet, PairingHeap, PairingNode, type Point, type Point2D, PriorityQueue, type ProgressCallback, QuadTree, Queue, RadixTree, type Rect, RedBlackTree, SMTPProvider, SegmentTree, type SendEmailOptions, Set, SinglyLinkedList, SparseTable, SplayTree, Stack, StaticArray, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, TreeNode, Trie, type UploadOptions, asyncHandler, authMiddleware, connectMongoDB, createAllowedOrigins, createCorsOptions, days, errorToString, hours, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as express from 'express';
|
|
2
2
|
import { Request, Response, NextFunction } from 'express';
|
|
3
|
-
import { Model, PopulateOptions, Query } from 'mongoose';
|
|
3
|
+
import { Model, PopulateOptions, Query, UpdateQuery } from 'mongoose';
|
|
4
4
|
import { ZodTypeAny, infer } from 'zod';
|
|
5
5
|
import { CorsOptions } from 'cors';
|
|
6
6
|
import { Schema } from 'joi';
|
|
@@ -1826,6 +1826,47 @@ declare const GlobalErrorHandler: (isProd?: boolean) => (err: unknown, _req: Req
|
|
|
1826
1826
|
|
|
1827
1827
|
declare const validate: (schema: Schema) => (req: Request, _res: Response, next: NextFunction) => void;
|
|
1828
1828
|
|
|
1829
|
+
interface IRepository<T> {
|
|
1830
|
+
findAll(filter?: any, options?: any): Promise<T[]>;
|
|
1831
|
+
findById(id: string): Promise<T | null>;
|
|
1832
|
+
findOne(filter: any): Promise<T | null>;
|
|
1833
|
+
create(data: Partial<T>): Promise<T>;
|
|
1834
|
+
updateById(id: string, data: Partial<T>): Promise<T | null>;
|
|
1835
|
+
deleteById(id: string): Promise<T | null>;
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
declare class BaseMongoRepository<T> implements IRepository<T> {
|
|
1839
|
+
protected model: Model<T>;
|
|
1840
|
+
constructor(model: Model<T>);
|
|
1841
|
+
findAll(filter?: Record<string, any>, options?: {
|
|
1842
|
+
select?: string;
|
|
1843
|
+
sort?: any;
|
|
1844
|
+
limit?: number;
|
|
1845
|
+
skip?: number;
|
|
1846
|
+
}): Promise<T[]>;
|
|
1847
|
+
findById(id: string): Promise<T | null>;
|
|
1848
|
+
findOne(filter: Record<string, any>): Promise<T | null>;
|
|
1849
|
+
create(data: Partial<T>): Promise<T>;
|
|
1850
|
+
updateById(id: string, data: UpdateQuery<T>): Promise<T | null>;
|
|
1851
|
+
deleteById(id: string): Promise<T | null>;
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
declare class BasePostgresRepository<T> implements IRepository<T> {
|
|
1855
|
+
protected model: any;
|
|
1856
|
+
constructor(model: any);
|
|
1857
|
+
findAll(filter?: Record<string, any>, options?: {
|
|
1858
|
+
select?: any;
|
|
1859
|
+
sort?: any;
|
|
1860
|
+
limit?: number;
|
|
1861
|
+
skip?: number;
|
|
1862
|
+
}): Promise<T[]>;
|
|
1863
|
+
findById(id: string): Promise<T | null>;
|
|
1864
|
+
findOne(filter: Record<string, any>): Promise<T | null>;
|
|
1865
|
+
create(data: Partial<T>): Promise<T>;
|
|
1866
|
+
updateById(id: string, data: Partial<T>): Promise<T | null>;
|
|
1867
|
+
deleteById(id: string): Promise<T | null>;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1829
1870
|
interface AzureBlobStorageConfig {
|
|
1830
1871
|
connectionString: string;
|
|
1831
1872
|
accountName: string;
|
|
@@ -1972,4 +2013,4 @@ declare function toMinutes(ms: number): number;
|
|
|
1972
2013
|
declare function toHours(ms: number): number;
|
|
1973
2014
|
declare function sleep(ms: number): Promise<void>;
|
|
1974
2015
|
|
|
1975
|
-
export { APIFactory, APIFeatures, APIResponse, AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, type AllowedOriginsOptions, AppError, type AzureBlobStorageConfig, AzureBlobStorageService, BPlusTree, BTree, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, type CloudinaryConfig, CloudinaryService, ConsistentHash, CountMinSketch, type DatabaseConfig, Deque, type DirectedEdge, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, type Edge, type EmailProvider, EmailService, FenwickTree, FibNode, FibonacciHeap, GlobalErrorHandler, Graph, HashMap, HashSet, HyperLogLog, type Interval, IntervalTree, JWTService, type JWTServiceOptions, KDTree, LFUCache, LRUCache, type LoggerOptions, MaxHeap, MaxStack, MinHeap, MinStack, MulterFileHandlerService, MultiSet, Node, OrderedSet, PairingHeap, PairingNode, type Point, type Point2D, PriorityQueue, type ProgressCallback, QuadTree, Queue, RadixTree, type Rect, RedBlackTree, SMTPProvider, SegmentTree, type SendEmailOptions, Set, SinglyLinkedList, SparseTable, SplayTree, Stack, StaticArray, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, TreeNode, Trie, type UploadOptions, asyncHandler, authMiddleware, connectMongoDB, createAllowedOrigins, createCorsOptions, days, errorToString, hours, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
|
|
2016
|
+
export { APIFactory, APIFeatures, APIResponse, AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, type AllowedOriginsOptions, AppError, type AzureBlobStorageConfig, AzureBlobStorageService, BPlusTree, BTree, BaseMongoRepository, BasePostgresRepository, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, type CloudinaryConfig, CloudinaryService, ConsistentHash, CountMinSketch, type DatabaseConfig, Deque, type DirectedEdge, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, type Edge, type EmailProvider, EmailService, FenwickTree, FibNode, FibonacciHeap, GlobalErrorHandler, Graph, HashMap, HashSet, HyperLogLog, type IRepository, type Interval, IntervalTree, JWTService, type JWTServiceOptions, KDTree, LFUCache, LRUCache, type LoggerOptions, MaxHeap, MaxStack, MinHeap, MinStack, MulterFileHandlerService, MultiSet, Node, OrderedSet, PairingHeap, PairingNode, type Point, type Point2D, PriorityQueue, type ProgressCallback, QuadTree, Queue, RadixTree, type Rect, RedBlackTree, SMTPProvider, SegmentTree, type SendEmailOptions, Set, SinglyLinkedList, SparseTable, SplayTree, Stack, StaticArray, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, TreeNode, Trie, type UploadOptions, asyncHandler, authMiddleware, connectMongoDB, createAllowedOrigins, createCorsOptions, days, errorToString, hours, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
|
package/dist/index.js
CHANGED
|
@@ -5161,6 +5161,84 @@ var validate = (schema) => (req, _res, next) => {
|
|
|
5161
5161
|
}
|
|
5162
5162
|
next();
|
|
5163
5163
|
};
|
|
5164
|
+
|
|
5165
|
+
// src/repositories/mongo.repository.ts
|
|
5166
|
+
var BaseMongoRepository = class {
|
|
5167
|
+
model;
|
|
5168
|
+
constructor(model) {
|
|
5169
|
+
this.model = model;
|
|
5170
|
+
}
|
|
5171
|
+
async findAll(filter = {}, options = {}) {
|
|
5172
|
+
let query = this.model.find(filter);
|
|
5173
|
+
if (options.select) query = query.select(options.select);
|
|
5174
|
+
if (options.sort) query = query.sort(options.sort);
|
|
5175
|
+
if (options.limit) query = query.limit(options.limit);
|
|
5176
|
+
if (options.skip) query = query.skip(options.skip);
|
|
5177
|
+
return query.exec();
|
|
5178
|
+
}
|
|
5179
|
+
async findById(id) {
|
|
5180
|
+
return this.model.findById(id).exec();
|
|
5181
|
+
}
|
|
5182
|
+
async findOne(filter) {
|
|
5183
|
+
return this.model.findOne(filter).exec();
|
|
5184
|
+
}
|
|
5185
|
+
async create(data) {
|
|
5186
|
+
return this.model.create(data);
|
|
5187
|
+
}
|
|
5188
|
+
async updateById(id, data) {
|
|
5189
|
+
return this.model.findByIdAndUpdate(id, data, {
|
|
5190
|
+
new: true,
|
|
5191
|
+
runValidators: true
|
|
5192
|
+
}).exec();
|
|
5193
|
+
}
|
|
5194
|
+
async deleteById(id) {
|
|
5195
|
+
return this.model.findByIdAndDelete(id).exec();
|
|
5196
|
+
}
|
|
5197
|
+
};
|
|
5198
|
+
|
|
5199
|
+
// src/repositories/postgres.repository.ts
|
|
5200
|
+
var BasePostgresRepository = class {
|
|
5201
|
+
model;
|
|
5202
|
+
// prisma model (e.g. prisma.testPost)
|
|
5203
|
+
constructor(model) {
|
|
5204
|
+
this.model = model;
|
|
5205
|
+
}
|
|
5206
|
+
async findAll(filter = {}, options = {}) {
|
|
5207
|
+
return this.model.findMany({
|
|
5208
|
+
where: filter,
|
|
5209
|
+
select: options.select,
|
|
5210
|
+
orderBy: options.sort,
|
|
5211
|
+
take: options.limit,
|
|
5212
|
+
skip: options.skip
|
|
5213
|
+
});
|
|
5214
|
+
}
|
|
5215
|
+
async findById(id) {
|
|
5216
|
+
return this.model.findUnique({
|
|
5217
|
+
where: { id }
|
|
5218
|
+
});
|
|
5219
|
+
}
|
|
5220
|
+
async findOne(filter) {
|
|
5221
|
+
return this.model.findFirst({
|
|
5222
|
+
where: filter
|
|
5223
|
+
});
|
|
5224
|
+
}
|
|
5225
|
+
async create(data) {
|
|
5226
|
+
return this.model.create({
|
|
5227
|
+
data
|
|
5228
|
+
});
|
|
5229
|
+
}
|
|
5230
|
+
async updateById(id, data) {
|
|
5231
|
+
return this.model.update({
|
|
5232
|
+
where: { id },
|
|
5233
|
+
data
|
|
5234
|
+
});
|
|
5235
|
+
}
|
|
5236
|
+
async deleteById(id) {
|
|
5237
|
+
return this.model.delete({
|
|
5238
|
+
where: { id }
|
|
5239
|
+
});
|
|
5240
|
+
}
|
|
5241
|
+
};
|
|
5164
5242
|
var AzureBlobStorageService = class {
|
|
5165
5243
|
containerName;
|
|
5166
5244
|
blobServiceClient;
|
|
@@ -5612,6 +5690,6 @@ function sleep(ms) {
|
|
|
5612
5690
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
5613
5691
|
}
|
|
5614
5692
|
|
|
5615
|
-
export { APIFactory, apiFeatures_default as APIFeatures, APIResponse, AVLTree, AdjacencyList, AdjacencyMatrix, AppError, AzureBlobStorageService, BPlusTree, BTree, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, CloudinaryService, ConsistentHash, CountMinSketch, Deque, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, EmailService, FenwickTree, FibNode, FibonacciHeap, GlobalErrorHandler, Graph, HashMap, HashSet, HyperLogLog, IntervalTree, JWTService, KDTree, LFUCache, LRUCache, MaxHeap, MaxStack, MinHeap, MinStack, MulterFileHandlerService, MultiSet, Node, OrderedSet, PairingHeap, PairingNode, PriorityQueue, QuadTree, Queue, RadixTree, RedBlackTree, SMTPProvider, SegmentTree, Set2 as Set, SinglyLinkedList, SparseTable, SplayTree, Stack, StaticArray, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, TreeNode, Trie, asyncHandler, authMiddleware, connectMongoDB, createAllowedOrigins, createCorsOptions, days, errorToString, hours, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
|
|
5693
|
+
export { APIFactory, apiFeatures_default as APIFeatures, APIResponse, AVLTree, AdjacencyList, AdjacencyMatrix, AppError, AzureBlobStorageService, BPlusTree, BTree, BaseMongoRepository, BasePostgresRepository, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, CloudinaryService, ConsistentHash, CountMinSketch, Deque, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, EmailService, FenwickTree, FibNode, FibonacciHeap, GlobalErrorHandler, Graph, HashMap, HashSet, HyperLogLog, IntervalTree, JWTService, KDTree, LFUCache, LRUCache, MaxHeap, MaxStack, MinHeap, MinStack, MulterFileHandlerService, MultiSet, Node, OrderedSet, PairingHeap, PairingNode, PriorityQueue, QuadTree, Queue, RadixTree, RedBlackTree, SMTPProvider, SegmentTree, Set2 as Set, SinglyLinkedList, SparseTable, SplayTree, Stack, StaticArray, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, TreeNode, Trie, asyncHandler, authMiddleware, connectMongoDB, createAllowedOrigins, createCorsOptions, days, errorToString, hours, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
|
|
5616
5694
|
//# sourceMappingURL=index.js.map
|
|
5617
5695
|
//# sourceMappingURL=index.js.map
|