elseware-nodejs 1.11.4 → 1.11.6
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/dist/index.cjs +39 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -12
- package/dist/index.d.ts +15 -12
- package/dist/index.js +39 -29
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ZodTypeAny,
|
|
1
|
+
import { ZodTypeAny, z, ZodSchema } from 'zod';
|
|
2
2
|
import { CorsOptions } from 'cors';
|
|
3
3
|
import * as express from 'express';
|
|
4
4
|
import { Request, Response, NextFunction, RequestHandler } from 'express';
|
|
@@ -8,14 +8,13 @@ import { Schema } from 'joi';
|
|
|
8
8
|
import { Model, UpdateQuery } from 'mongoose';
|
|
9
9
|
import { SignOptions, JwtPayload } from 'jsonwebtoken';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
interface LoadEnvOptions<TSchema extends ZodTypeAny, TOutput = infer<TSchema>> {
|
|
11
|
+
type InferSchema<TSchema extends ZodTypeAny> = z.infer<TSchema>;
|
|
12
|
+
interface LoadEnvOptions<TSchema extends ZodTypeAny, TOutput = InferSchema<TSchema>> {
|
|
14
13
|
schema: TSchema;
|
|
15
|
-
transform?: (env:
|
|
14
|
+
transform?: (env: InferSchema<TSchema>) => TOutput;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
declare function loadEnv<TSchema extends ZodTypeAny, TOutput =
|
|
17
|
+
declare function loadEnv<TSchema extends ZodTypeAny, TOutput = InferSchema<TSchema>>(options: LoadEnvOptions<TSchema, TOutput>): TOutput;
|
|
19
18
|
|
|
20
19
|
interface AppErrorOptions {
|
|
21
20
|
code?: string;
|
|
@@ -1755,14 +1754,18 @@ declare class SegmentTree<T> {
|
|
|
1755
1754
|
private updatePoint;
|
|
1756
1755
|
}
|
|
1757
1756
|
|
|
1758
|
-
interface
|
|
1759
|
-
|
|
1760
|
-
|
|
1757
|
+
interface CorsOptionsConfig {
|
|
1758
|
+
allowedOrigins: string[];
|
|
1759
|
+
allowCredentials?: boolean;
|
|
1760
|
+
allowedMethods?: string[];
|
|
1761
|
+
allowedHeaders?: string[];
|
|
1762
|
+
exposedHeaders?: string[];
|
|
1763
|
+
optionsSuccessStatus?: number;
|
|
1761
1764
|
}
|
|
1762
1765
|
|
|
1763
|
-
declare function
|
|
1766
|
+
declare function createCorsOptions(config: CorsOptionsConfig): CorsOptions;
|
|
1764
1767
|
|
|
1765
|
-
declare function
|
|
1768
|
+
declare function isAllowedOrigin(origin: string, allowedOrigins: string[]): boolean;
|
|
1766
1769
|
|
|
1767
1770
|
interface DatabaseProvider {
|
|
1768
1771
|
connect(): Promise<void>;
|
|
@@ -2336,4 +2339,4 @@ declare function toMinutes(ms: number): number;
|
|
|
2336
2339
|
declare function toHours(ms: number): number;
|
|
2337
2340
|
declare function sleep(ms: number): Promise<void>;
|
|
2338
2341
|
|
|
2339
|
-
export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge,
|
|
2342
|
+
export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, ApiFeatures, type ApiMeta, ApiResponse, type ApiResponseOptions, AppError, type AppErrorOptions, AsyncHandler, type AsyncRequestHandler, type AuthStrategy, type AuthenticatedUser, type AzureBlobStorageConfig, AzureBlobStorageService, BPlusTree, BTree, BearerTokenStrategy, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, type CloudinaryConfig, CloudinaryService, ConsistentHash, CorrelationId, type CorsOptionsConfig, CountMinSketch, CrudControllerFactory, type CrudControllerOptions, DEFAULT_LIMIT, DEFAULT_PAGE, DEFAULT_SORT_DIRECTION, type DatabaseConnectionOptions, DatabaseManager, type DatabaseProvider, Deque, type DirectedEdge, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, type Edge, type EmailProvider, EmailService, type ErrorMeta, ErrorMiddleware, type ExponentialBackoffOptions, ExponentialBackoffRetryPolicy, FenwickTree, FibNode, FibonacciHeap, type Filter, FixedRetryPolicy, type FixedRetryPolicyOptions, Graph, HashMap, HashSet, HttpClient, type HttpClientOptions, HyperLogLog, type IValidator, type InferSchema, InternalServiceClient, type Interval, IntervalTree, JWTService, type JWTServiceOptions, JoiValidator, KDTree, LFUCache, LRUCache, type LoadEnvOptions, Logger, type LoggerOptions, MaxHeap, MaxStack, MinHeap, MinStack, type MongoDatabaseConfig, MongoDatabaseProvider, MongoRepository, MulterFileHandlerService, MultiSet, Node, OrderedSet, type PaginationMeta, type PaginationQuery, PairingHeap, PairingNode, type ParsedQuery, type PickOptions, type Point, type Point2D, PriorityQueue, type ProgressCallback, QUERY_RESERVED_FIELDS, QuadTree, type QueryFilter, type QueryOperator, type QueryOptions, type QuerySort, Queue, RadixTree, type Rect, RedBlackTree, type Repository, RequestContext, type RequestContextData, type RequestContextOptions, type RetryPolicy, SMTPProvider, SUPPORTED_OPERATORS, SegmentTree, type Select, type SendEmailOptions, ServiceClient, type ServiceResponse, Set, SinglyLinkedList, type Sort, SparseTable, SplayTree, Stack, type StandardApiResponse, StaticArray, StaticTokenProvider, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, type TokenProvider, TracingHeaders, TreeNode, Trie, type UpdateQueryOptions, type UploadOptions, type ValidationResult, type ValidationSchema, ZodValidator, authMiddleware, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isAllowedOrigin, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ZodTypeAny,
|
|
1
|
+
import { ZodTypeAny, z, ZodSchema } from 'zod';
|
|
2
2
|
import { CorsOptions } from 'cors';
|
|
3
3
|
import * as express from 'express';
|
|
4
4
|
import { Request, Response, NextFunction, RequestHandler } from 'express';
|
|
@@ -8,14 +8,13 @@ import { Schema } from 'joi';
|
|
|
8
8
|
import { Model, UpdateQuery } from 'mongoose';
|
|
9
9
|
import { SignOptions, JwtPayload } from 'jsonwebtoken';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
interface LoadEnvOptions<TSchema extends ZodTypeAny, TOutput = infer<TSchema>> {
|
|
11
|
+
type InferSchema<TSchema extends ZodTypeAny> = z.infer<TSchema>;
|
|
12
|
+
interface LoadEnvOptions<TSchema extends ZodTypeAny, TOutput = InferSchema<TSchema>> {
|
|
14
13
|
schema: TSchema;
|
|
15
|
-
transform?: (env:
|
|
14
|
+
transform?: (env: InferSchema<TSchema>) => TOutput;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
declare function loadEnv<TSchema extends ZodTypeAny, TOutput =
|
|
17
|
+
declare function loadEnv<TSchema extends ZodTypeAny, TOutput = InferSchema<TSchema>>(options: LoadEnvOptions<TSchema, TOutput>): TOutput;
|
|
19
18
|
|
|
20
19
|
interface AppErrorOptions {
|
|
21
20
|
code?: string;
|
|
@@ -1755,14 +1754,18 @@ declare class SegmentTree<T> {
|
|
|
1755
1754
|
private updatePoint;
|
|
1756
1755
|
}
|
|
1757
1756
|
|
|
1758
|
-
interface
|
|
1759
|
-
|
|
1760
|
-
|
|
1757
|
+
interface CorsOptionsConfig {
|
|
1758
|
+
allowedOrigins: string[];
|
|
1759
|
+
allowCredentials?: boolean;
|
|
1760
|
+
allowedMethods?: string[];
|
|
1761
|
+
allowedHeaders?: string[];
|
|
1762
|
+
exposedHeaders?: string[];
|
|
1763
|
+
optionsSuccessStatus?: number;
|
|
1761
1764
|
}
|
|
1762
1765
|
|
|
1763
|
-
declare function
|
|
1766
|
+
declare function createCorsOptions(config: CorsOptionsConfig): CorsOptions;
|
|
1764
1767
|
|
|
1765
|
-
declare function
|
|
1768
|
+
declare function isAllowedOrigin(origin: string, allowedOrigins: string[]): boolean;
|
|
1766
1769
|
|
|
1767
1770
|
interface DatabaseProvider {
|
|
1768
1771
|
connect(): Promise<void>;
|
|
@@ -2336,4 +2339,4 @@ declare function toMinutes(ms: number): number;
|
|
|
2336
2339
|
declare function toHours(ms: number): number;
|
|
2337
2340
|
declare function sleep(ms: number): Promise<void>;
|
|
2338
2341
|
|
|
2339
|
-
export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge,
|
|
2342
|
+
export { AVLTree, AdjacencyList, AdjacencyMatrix, type AdjacentEdge, ApiFeatures, type ApiMeta, ApiResponse, type ApiResponseOptions, AppError, type AppErrorOptions, AsyncHandler, type AsyncRequestHandler, type AuthStrategy, type AuthenticatedUser, type AzureBlobStorageConfig, AzureBlobStorageService, BPlusTree, BTree, BearerTokenStrategy, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, type CloudinaryConfig, CloudinaryService, ConsistentHash, CorrelationId, type CorsOptionsConfig, CountMinSketch, CrudControllerFactory, type CrudControllerOptions, DEFAULT_LIMIT, DEFAULT_PAGE, DEFAULT_SORT_DIRECTION, type DatabaseConnectionOptions, DatabaseManager, type DatabaseProvider, Deque, type DirectedEdge, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, type Edge, type EmailProvider, EmailService, type ErrorMeta, ErrorMiddleware, type ExponentialBackoffOptions, ExponentialBackoffRetryPolicy, FenwickTree, FibNode, FibonacciHeap, type Filter, FixedRetryPolicy, type FixedRetryPolicyOptions, Graph, HashMap, HashSet, HttpClient, type HttpClientOptions, HyperLogLog, type IValidator, type InferSchema, InternalServiceClient, type Interval, IntervalTree, JWTService, type JWTServiceOptions, JoiValidator, KDTree, LFUCache, LRUCache, type LoadEnvOptions, Logger, type LoggerOptions, MaxHeap, MaxStack, MinHeap, MinStack, type MongoDatabaseConfig, MongoDatabaseProvider, MongoRepository, MulterFileHandlerService, MultiSet, Node, OrderedSet, type PaginationMeta, type PaginationQuery, PairingHeap, PairingNode, type ParsedQuery, type PickOptions, type Point, type Point2D, PriorityQueue, type ProgressCallback, QUERY_RESERVED_FIELDS, QuadTree, type QueryFilter, type QueryOperator, type QueryOptions, type QuerySort, Queue, RadixTree, type Rect, RedBlackTree, type Repository, RequestContext, type RequestContextData, type RequestContextOptions, type RetryPolicy, SMTPProvider, SUPPORTED_OPERATORS, SegmentTree, type Select, type SendEmailOptions, ServiceClient, type ServiceResponse, Set, SinglyLinkedList, type Sort, SparseTable, SplayTree, Stack, type StandardApiResponse, StaticArray, StaticTokenProvider, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, type TokenProvider, TracingHeaders, TreeNode, Trie, type UpdateQueryOptions, type UploadOptions, type ValidationResult, type ValidationSchema, ZodValidator, authMiddleware, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isAllowedOrigin, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
|
package/dist/index.js
CHANGED
|
@@ -12,8 +12,7 @@ import juice from 'juice';
|
|
|
12
12
|
import jwt from 'jsonwebtoken';
|
|
13
13
|
import multer from 'multer';
|
|
14
14
|
|
|
15
|
-
// src/core/
|
|
16
|
-
var DEFAULT_ALLOWED_ORIGINS = ["http://localhost:3000"];
|
|
15
|
+
// src/core/environment/loadEnv.ts
|
|
17
16
|
|
|
18
17
|
// src/utils/errorToString.ts
|
|
19
18
|
function errorToString(error) {
|
|
@@ -4848,41 +4847,52 @@ var SegmentTree = class {
|
|
|
4848
4847
|
}
|
|
4849
4848
|
};
|
|
4850
4849
|
|
|
4851
|
-
// src/infrastructure/cors/
|
|
4852
|
-
function
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4850
|
+
// src/infrastructure/cors/isAllowedOrigin.ts
|
|
4851
|
+
function isAllowedOrigin(origin, allowedOrigins) {
|
|
4852
|
+
return allowedOrigins.some((allowedOrigin) => {
|
|
4853
|
+
if (allowedOrigin === "*") {
|
|
4854
|
+
return true;
|
|
4855
|
+
}
|
|
4856
|
+
if (allowedOrigin === origin) {
|
|
4857
|
+
return true;
|
|
4858
|
+
}
|
|
4859
|
+
if (allowedOrigin.startsWith("*.") && origin.endsWith(allowedOrigin.slice(1))) {
|
|
4860
|
+
return true;
|
|
4861
|
+
}
|
|
4862
|
+
return false;
|
|
4863
|
+
});
|
|
4865
4864
|
}
|
|
4866
4865
|
|
|
4867
4866
|
// src/infrastructure/cors/createCorsOptions.ts
|
|
4868
|
-
function createCorsOptions(
|
|
4867
|
+
function createCorsOptions(config) {
|
|
4868
|
+
const {
|
|
4869
|
+
allowedOrigins,
|
|
4870
|
+
allowCredentials = true,
|
|
4871
|
+
allowedMethods = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
|
|
4872
|
+
allowedHeaders = [
|
|
4873
|
+
"Content-Type",
|
|
4874
|
+
"Authorization",
|
|
4875
|
+
"X-Requested-With",
|
|
4876
|
+
"Accept"
|
|
4877
|
+
],
|
|
4878
|
+
exposedHeaders = ["Set-Cookie"],
|
|
4879
|
+
optionsSuccessStatus = 204
|
|
4880
|
+
} = config;
|
|
4869
4881
|
return {
|
|
4870
4882
|
origin(origin, callback) {
|
|
4871
|
-
if (!origin
|
|
4883
|
+
if (!origin) {
|
|
4884
|
+
return callback(null, true);
|
|
4885
|
+
}
|
|
4886
|
+
if (isAllowedOrigin(origin, allowedOrigins)) {
|
|
4872
4887
|
return callback(null, true);
|
|
4873
4888
|
}
|
|
4874
4889
|
return callback(new Error(`CORS blocked: ${origin} is not allowed`));
|
|
4875
4890
|
},
|
|
4876
|
-
credentials:
|
|
4877
|
-
methods:
|
|
4878
|
-
allowedHeaders
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
"X-Requested-With",
|
|
4882
|
-
"Accept"
|
|
4883
|
-
],
|
|
4884
|
-
exposedHeaders: ["Set-Cookie"],
|
|
4885
|
-
optionsSuccessStatus: 204
|
|
4891
|
+
credentials: allowCredentials,
|
|
4892
|
+
methods: allowedMethods,
|
|
4893
|
+
allowedHeaders,
|
|
4894
|
+
exposedHeaders,
|
|
4895
|
+
optionsSuccessStatus
|
|
4886
4896
|
};
|
|
4887
4897
|
}
|
|
4888
4898
|
|
|
@@ -6320,6 +6330,6 @@ function sleep(ms) {
|
|
|
6320
6330
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
6321
6331
|
}
|
|
6322
6332
|
|
|
6323
|
-
export { AVLTree, AdjacencyList, AdjacencyMatrix, ApiFeatures, ApiResponse, AppError, AsyncHandler, AzureBlobStorageService, BPlusTree, BTree, BearerTokenStrategy, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, CloudinaryService, ConsistentHash, CorrelationId, CountMinSketch, CrudControllerFactory,
|
|
6333
|
+
export { AVLTree, AdjacencyList, AdjacencyMatrix, ApiFeatures, ApiResponse, AppError, AsyncHandler, AzureBlobStorageService, BPlusTree, BTree, BearerTokenStrategy, BinaryHeap, BinarySearchTree, BinaryTree, BloomFilter, CircularArray, CircularLinkedList, CircularQueue, CloudinaryService, ConsistentHash, CorrelationId, CountMinSketch, CrudControllerFactory, DEFAULT_LIMIT, DEFAULT_PAGE, DEFAULT_SORT_DIRECTION, DatabaseManager, Deque, DirectedGraph, DisjointSetUnion, DoublyLinkedList, DynamicArray, EmailService, ErrorMiddleware, ExponentialBackoffRetryPolicy, FenwickTree, FibNode, FibonacciHeap, FixedRetryPolicy, Graph, HashMap, HashSet, HttpClient, HyperLogLog, InternalServiceClient, IntervalTree, JWTService, JoiValidator, KDTree, LFUCache, LRUCache, Logger, MaxHeap, MaxStack, MinHeap, MinStack, MongoDatabaseProvider, MongoRepository, MulterFileHandlerService, MultiSet, Node, OrderedSet, PairingHeap, PairingNode, PriorityQueue, QUERY_RESERVED_FIELDS, QuadTree, Queue, RadixTree, RedBlackTree, RequestContext, SMTPProvider, SUPPORTED_OPERATORS, SegmentTree, ServiceClient, Set2 as Set, SinglyLinkedList, SparseTable, SplayTree, Stack, StaticArray, StaticTokenProvider, SuffixArray, SuffixTree, TemplateEngine, TernarySearchTree, TracingHeaders, TreeNode, Trie, ZodValidator, authMiddleware, createCorsOptions, createRequestContextMiddleware, days, errorToString, hours, isAllowedOrigin, isJoiSchema, isZodSchema, loadEnv, logger, milliseconds, minutes, pickFields, seconds, sleep, toHours, toMinutes, toSeconds, validate };
|
|
6324
6334
|
//# sourceMappingURL=index.js.map
|
|
6325
6335
|
//# sourceMappingURL=index.js.map
|