@arcraz/common 1.0.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/LICENSE +190 -0
- package/README.md +373 -0
- package/dist/aws/bedrock/client-factory.d.ts +45 -0
- package/dist/aws/bedrock/client-factory.d.ts.map +1 -0
- package/dist/aws/bedrock/client-factory.js +113 -0
- package/dist/aws/bedrock/index.d.ts +3 -0
- package/dist/aws/bedrock/index.d.ts.map +1 -0
- package/dist/aws/bedrock/index.js +1 -0
- package/dist/aws/bedrock/types.d.ts +95 -0
- package/dist/aws/bedrock/types.d.ts.map +1 -0
- package/dist/aws/bedrock/types.js +1 -0
- package/dist/aws/cloudfront/index.d.ts +3 -0
- package/dist/aws/cloudfront/index.d.ts.map +1 -0
- package/dist/aws/cloudfront/index.js +1 -0
- package/dist/aws/cloudfront/signer-factory.d.ts +36 -0
- package/dist/aws/cloudfront/signer-factory.d.ts.map +1 -0
- package/dist/aws/cloudfront/signer-factory.js +75 -0
- package/dist/aws/cloudfront/types.d.ts +52 -0
- package/dist/aws/cloudfront/types.d.ts.map +1 -0
- package/dist/aws/cloudfront/types.js +1 -0
- package/dist/aws/s3/client-factory.d.ts +13 -0
- package/dist/aws/s3/client-factory.d.ts.map +1 -0
- package/dist/aws/s3/client-factory.js +25 -0
- package/dist/aws/s3/index.d.ts +4 -0
- package/dist/aws/s3/index.d.ts.map +1 -0
- package/dist/aws/s3/index.js +2 -0
- package/dist/aws/s3/operations.d.ts +106 -0
- package/dist/aws/s3/operations.d.ts.map +1 -0
- package/dist/aws/s3/operations.js +234 -0
- package/dist/aws/s3/types.d.ts +88 -0
- package/dist/aws/s3/types.d.ts.map +1 -0
- package/dist/aws/s3/types.js +1 -0
- package/dist/caches/api-cache.d.ts +40 -0
- package/dist/caches/api-cache.d.ts.map +1 -0
- package/dist/caches/api-cache.js +65 -0
- package/dist/caches/database-cache.d.ts +40 -0
- package/dist/caches/database-cache.d.ts.map +1 -0
- package/dist/caches/database-cache.js +65 -0
- package/dist/caches/index.d.ts +3 -0
- package/dist/caches/index.d.ts.map +1 -0
- package/dist/caches/index.js +2 -0
- package/dist/config/env-loader.d.ts +28 -0
- package/dist/config/env-loader.d.ts.map +1 -0
- package/dist/config/env-loader.js +39 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +2 -0
- package/dist/config/schemas.d.ts +193 -0
- package/dist/config/schemas.d.ts.map +1 -0
- package/dist/config/schemas.js +92 -0
- package/dist/config/types.d.ts +23 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +2 -0
- package/dist/constants/cache-durations.d.ts +29 -0
- package/dist/constants/cache-durations.d.ts.map +1 -0
- package/dist/constants/cache-durations.js +27 -0
- package/dist/constants/defaults.d.ts +50 -0
- package/dist/constants/defaults.d.ts.map +1 -0
- package/dist/constants/defaults.js +49 -0
- package/dist/constants/index.d.ts +4 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +2 -0
- package/dist/database/base-repository.d.ts +45 -0
- package/dist/database/base-repository.d.ts.map +1 -0
- package/dist/database/base-repository.js +57 -0
- package/dist/database/helpers/converter-helper.d.ts +9 -0
- package/dist/database/helpers/converter-helper.d.ts.map +1 -0
- package/dist/database/helpers/converter-helper.js +20 -0
- package/dist/database/helpers/index.d.ts +3 -0
- package/dist/database/helpers/index.d.ts.map +1 -0
- package/dist/database/helpers/index.js +2 -0
- package/dist/database/helpers/paged-response-helper.d.ts +33 -0
- package/dist/database/helpers/paged-response-helper.d.ts.map +1 -0
- package/dist/database/helpers/paged-response-helper.js +64 -0
- package/dist/database/index.d.ts +6 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js +4 -0
- package/dist/database/pool-factory.d.ts +24 -0
- package/dist/database/pool-factory.d.ts.map +1 -0
- package/dist/database/pool-factory.js +91 -0
- package/dist/database/query-helpers.d.ts +36 -0
- package/dist/database/query-helpers.d.ts.map +1 -0
- package/dist/database/query-helpers.js +68 -0
- package/dist/database/types.d.ts +55 -0
- package/dist/database/types.d.ts.map +1 -0
- package/dist/database/types.js +1 -0
- package/dist/helpers/data-obscurer.d.ts +18 -0
- package/dist/helpers/data-obscurer.d.ts.map +1 -0
- package/dist/helpers/data-obscurer.js +29 -0
- package/dist/helpers/enum-converters.d.ts +27 -0
- package/dist/helpers/enum-converters.d.ts.map +1 -0
- package/dist/helpers/enum-converters.js +37 -0
- package/dist/helpers/index.d.ts +5 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +3 -0
- package/dist/helpers/remove-sensitive-values.d.ts +20 -0
- package/dist/helpers/remove-sensitive-values.d.ts.map +1 -0
- package/dist/helpers/remove-sensitive-values.js +72 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/logging/formatters.d.ts +19 -0
- package/dist/logging/formatters.d.ts.map +1 -0
- package/dist/logging/formatters.js +94 -0
- package/dist/logging/index.d.ts +4 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +2 -0
- package/dist/logging/logger-factory.d.ts +8 -0
- package/dist/logging/logger-factory.d.ts.map +1 -0
- package/dist/logging/logger-factory.js +86 -0
- package/dist/logging/types.d.ts +52 -0
- package/dist/logging/types.d.ts.map +1 -0
- package/dist/logging/types.js +1 -0
- package/dist/rabbitmq/connection-factory.d.ts +8 -0
- package/dist/rabbitmq/connection-factory.d.ts.map +1 -0
- package/dist/rabbitmq/connection-factory.js +117 -0
- package/dist/rabbitmq/consumer.d.ts +44 -0
- package/dist/rabbitmq/consumer.d.ts.map +1 -0
- package/dist/rabbitmq/consumer.js +107 -0
- package/dist/rabbitmq/index.d.ts +6 -0
- package/dist/rabbitmq/index.d.ts.map +1 -0
- package/dist/rabbitmq/index.js +4 -0
- package/dist/rabbitmq/namespace-helpers.d.ts +33 -0
- package/dist/rabbitmq/namespace-helpers.d.ts.map +1 -0
- package/dist/rabbitmq/namespace-helpers.js +44 -0
- package/dist/rabbitmq/publisher.d.ts +27 -0
- package/dist/rabbitmq/publisher.d.ts.map +1 -0
- package/dist/rabbitmq/publisher.js +94 -0
- package/dist/rabbitmq/types.d.ts +94 -0
- package/dist/rabbitmq/types.d.ts.map +1 -0
- package/dist/rabbitmq/types.js +1 -0
- package/dist/redis/client-factory.d.ts +14 -0
- package/dist/redis/client-factory.d.ts.map +1 -0
- package/dist/redis/client-factory.js +98 -0
- package/dist/redis/index.d.ts +6 -0
- package/dist/redis/index.d.ts.map +1 -0
- package/dist/redis/index.js +4 -0
- package/dist/redis/namespace-helpers.d.ts +33 -0
- package/dist/redis/namespace-helpers.d.ts.map +1 -0
- package/dist/redis/namespace-helpers.js +43 -0
- package/dist/redis/operations/index.d.ts +3 -0
- package/dist/redis/operations/index.d.ts.map +1 -0
- package/dist/redis/operations/index.js +2 -0
- package/dist/redis/operations/list.d.ts +102 -0
- package/dist/redis/operations/list.d.ts.map +1 -0
- package/dist/redis/operations/list.js +136 -0
- package/dist/redis/operations/standard.d.ts +85 -0
- package/dist/redis/operations/standard.d.ts.map +1 -0
- package/dist/redis/operations/standard.js +136 -0
- package/dist/redis/types.d.ts +81 -0
- package/dist/redis/types.d.ts.map +1 -0
- package/dist/redis/types.js +8 -0
- package/dist/security/cors-factory.d.ts +28 -0
- package/dist/security/cors-factory.d.ts.map +1 -0
- package/dist/security/cors-factory.js +73 -0
- package/dist/security/helmet-factory.d.ts +14 -0
- package/dist/security/helmet-factory.d.ts.map +1 -0
- package/dist/security/helmet-factory.js +80 -0
- package/dist/security/index.d.ts +4 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +2 -0
- package/dist/security/types.d.ts +103 -0
- package/dist/security/types.d.ts.map +1 -0
- package/dist/security/types.js +1 -0
- package/dist/types/custom-types.d.ts +102 -0
- package/dist/types/custom-types.d.ts.map +1 -0
- package/dist/types/custom-types.js +45 -0
- package/dist/types/enums.d.ts +26 -0
- package/dist/types/enums.d.ts.map +1 -0
- package/dist/types/enums.js +30 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/package.json +154 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { PutObjectCommand, GetObjectCommand, DeleteObjectCommand, DeleteObjectsCommand, HeadObjectCommand, ListObjectsV2Command, CopyObjectCommand } from '@aws-sdk/client-s3';
|
|
2
|
+
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
3
|
+
/**
|
|
4
|
+
* Uploads data to S3
|
|
5
|
+
* @param s3 S3 instance
|
|
6
|
+
* @param bucket Bucket name
|
|
7
|
+
* @param key Object key
|
|
8
|
+
* @param body Data to upload
|
|
9
|
+
* @param options Upload options
|
|
10
|
+
*/
|
|
11
|
+
export async function upload(s3, bucket, key, body, options = {}) {
|
|
12
|
+
const command = new PutObjectCommand({
|
|
13
|
+
Bucket: bucket,
|
|
14
|
+
Key: key,
|
|
15
|
+
Body: body,
|
|
16
|
+
ContentType: options.contentType,
|
|
17
|
+
CacheControl: options.cacheControl,
|
|
18
|
+
ContentDisposition: options.contentDisposition,
|
|
19
|
+
Metadata: options.metadata,
|
|
20
|
+
ACL: options.acl,
|
|
21
|
+
ServerSideEncryption: options.serverSideEncryption,
|
|
22
|
+
StorageClass: options.storageClass
|
|
23
|
+
});
|
|
24
|
+
await s3.client.send(command);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Downloads an object from S3
|
|
28
|
+
* @param s3 S3 instance
|
|
29
|
+
* @param bucket Bucket name
|
|
30
|
+
* @param key Object key
|
|
31
|
+
* @param options Download options
|
|
32
|
+
* @returns Object body as a readable stream
|
|
33
|
+
*/
|
|
34
|
+
export async function download(s3, bucket, key, options = {}) {
|
|
35
|
+
const command = new GetObjectCommand({
|
|
36
|
+
Bucket: bucket,
|
|
37
|
+
Key: key,
|
|
38
|
+
Range: options.range,
|
|
39
|
+
IfModifiedSince: options.ifModifiedSince,
|
|
40
|
+
IfUnmodifiedSince: options.ifUnmodifiedSince
|
|
41
|
+
});
|
|
42
|
+
const response = await s3.client.send(command);
|
|
43
|
+
return response.Body || null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Downloads an object as a buffer
|
|
47
|
+
* @param s3 S3 instance
|
|
48
|
+
* @param bucket Bucket name
|
|
49
|
+
* @param key Object key
|
|
50
|
+
* @returns Object body as a buffer
|
|
51
|
+
*/
|
|
52
|
+
export async function downloadAsBuffer(s3, bucket, key) {
|
|
53
|
+
const stream = await download(s3, bucket, key);
|
|
54
|
+
if (!stream)
|
|
55
|
+
return null;
|
|
56
|
+
const chunks = [];
|
|
57
|
+
for await (const chunk of stream) {
|
|
58
|
+
chunks.push(Buffer.from(chunk));
|
|
59
|
+
}
|
|
60
|
+
return Buffer.concat(chunks);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Downloads an object as a string
|
|
64
|
+
* @param s3 S3 instance
|
|
65
|
+
* @param bucket Bucket name
|
|
66
|
+
* @param key Object key
|
|
67
|
+
* @param encoding String encoding
|
|
68
|
+
* @returns Object body as a string
|
|
69
|
+
*/
|
|
70
|
+
export async function downloadAsString(s3, bucket, key, encoding = 'utf-8') {
|
|
71
|
+
const buffer = await downloadAsBuffer(s3, bucket, key);
|
|
72
|
+
return buffer ? buffer.toString(encoding) : null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Deletes an object from S3
|
|
76
|
+
* @param s3 S3 instance
|
|
77
|
+
* @param bucket Bucket name
|
|
78
|
+
* @param key Object key
|
|
79
|
+
*/
|
|
80
|
+
export async function deleteObject(s3, bucket, key) {
|
|
81
|
+
const command = new DeleteObjectCommand({
|
|
82
|
+
Bucket: bucket,
|
|
83
|
+
Key: key
|
|
84
|
+
});
|
|
85
|
+
await s3.client.send(command);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Deletes multiple objects from S3
|
|
89
|
+
* @param s3 S3 instance
|
|
90
|
+
* @param bucket Bucket name
|
|
91
|
+
* @param keys Object keys to delete
|
|
92
|
+
*/
|
|
93
|
+
export async function deleteObjects(s3, bucket, keys) {
|
|
94
|
+
if (keys.length === 0)
|
|
95
|
+
return;
|
|
96
|
+
const command = new DeleteObjectsCommand({
|
|
97
|
+
Bucket: bucket,
|
|
98
|
+
Delete: {
|
|
99
|
+
Objects: keys.map((key) => ({ Key: key }))
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
await s3.client.send(command);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Checks if an object exists in S3
|
|
106
|
+
* @param s3 S3 instance
|
|
107
|
+
* @param bucket Bucket name
|
|
108
|
+
* @param key Object key
|
|
109
|
+
* @returns True if object exists
|
|
110
|
+
*/
|
|
111
|
+
export async function exists(s3, bucket, key) {
|
|
112
|
+
try {
|
|
113
|
+
const command = new HeadObjectCommand({
|
|
114
|
+
Bucket: bucket,
|
|
115
|
+
Key: key
|
|
116
|
+
});
|
|
117
|
+
await s3.client.send(command);
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
if (error && typeof error === 'object' && 'name' in error && error.name === 'NotFound') {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Gets object metadata from S3
|
|
129
|
+
* @param s3 S3 instance
|
|
130
|
+
* @param bucket Bucket name
|
|
131
|
+
* @param key Object key
|
|
132
|
+
* @returns Object metadata or null if not found
|
|
133
|
+
*/
|
|
134
|
+
export async function getMetadata(s3, bucket, key) {
|
|
135
|
+
try {
|
|
136
|
+
const command = new HeadObjectCommand({
|
|
137
|
+
Bucket: bucket,
|
|
138
|
+
Key: key
|
|
139
|
+
});
|
|
140
|
+
const response = await s3.client.send(command);
|
|
141
|
+
return {
|
|
142
|
+
key,
|
|
143
|
+
size: response.ContentLength,
|
|
144
|
+
lastModified: response.LastModified,
|
|
145
|
+
etag: response.ETag,
|
|
146
|
+
storageClass: response.StorageClass
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
if (error && typeof error === 'object' && 'name' in error && error.name === 'NotFound') {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Lists objects in an S3 bucket
|
|
158
|
+
* @param s3 S3 instance
|
|
159
|
+
* @param bucket Bucket name
|
|
160
|
+
* @param options List options
|
|
161
|
+
* @returns List of object metadata and continuation token
|
|
162
|
+
*/
|
|
163
|
+
export async function listObjects(s3, bucket, options = {}) {
|
|
164
|
+
const command = new ListObjectsV2Command({
|
|
165
|
+
Bucket: bucket,
|
|
166
|
+
Prefix: options.prefix,
|
|
167
|
+
Delimiter: options.delimiter,
|
|
168
|
+
MaxKeys: options.maxKeys,
|
|
169
|
+
ContinuationToken: options.continuationToken
|
|
170
|
+
});
|
|
171
|
+
const response = await s3.client.send(command);
|
|
172
|
+
const objects = (response.Contents || []).map((item) => ({
|
|
173
|
+
key: item.Key || '',
|
|
174
|
+
size: item.Size,
|
|
175
|
+
lastModified: item.LastModified,
|
|
176
|
+
etag: item.ETag,
|
|
177
|
+
storageClass: item.StorageClass
|
|
178
|
+
}));
|
|
179
|
+
return {
|
|
180
|
+
objects,
|
|
181
|
+
continuationToken: response.NextContinuationToken
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Copies an object within S3
|
|
186
|
+
* @param s3 S3 instance
|
|
187
|
+
* @param sourceBucket Source bucket
|
|
188
|
+
* @param sourceKey Source key
|
|
189
|
+
* @param destBucket Destination bucket
|
|
190
|
+
* @param destKey Destination key
|
|
191
|
+
*/
|
|
192
|
+
export async function copyObject(s3, sourceBucket, sourceKey, destBucket, destKey) {
|
|
193
|
+
const command = new CopyObjectCommand({
|
|
194
|
+
CopySource: `${sourceBucket}/${sourceKey}`,
|
|
195
|
+
Bucket: destBucket,
|
|
196
|
+
Key: destKey
|
|
197
|
+
});
|
|
198
|
+
await s3.client.send(command);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Generates a presigned URL for downloading
|
|
202
|
+
* @param s3 S3 instance
|
|
203
|
+
* @param bucket Bucket name
|
|
204
|
+
* @param key Object key
|
|
205
|
+
* @param options Presigned URL options
|
|
206
|
+
* @returns Presigned URL
|
|
207
|
+
*/
|
|
208
|
+
export async function getPresignedDownloadUrl(s3, bucket, key, options = {}) {
|
|
209
|
+
const command = new GetObjectCommand({
|
|
210
|
+
Bucket: bucket,
|
|
211
|
+
Key: key
|
|
212
|
+
});
|
|
213
|
+
return getSignedUrl(s3.client, command, {
|
|
214
|
+
expiresIn: options.expiresIn || 3600
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Generates a presigned URL for uploading
|
|
219
|
+
* @param s3 S3 instance
|
|
220
|
+
* @param bucket Bucket name
|
|
221
|
+
* @param key Object key
|
|
222
|
+
* @param options Presigned URL options
|
|
223
|
+
* @returns Presigned URL
|
|
224
|
+
*/
|
|
225
|
+
export async function getPresignedUploadUrl(s3, bucket, key, options = {}) {
|
|
226
|
+
const command = new PutObjectCommand({
|
|
227
|
+
Bucket: bucket,
|
|
228
|
+
Key: key,
|
|
229
|
+
ContentType: options.contentType
|
|
230
|
+
});
|
|
231
|
+
return getSignedUrl(s3.client, command, {
|
|
232
|
+
expiresIn: options.expiresIn || 3600
|
|
233
|
+
});
|
|
234
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { S3Client } from '@aws-sdk/client-s3';
|
|
2
|
+
/**
|
|
3
|
+
* S3 client configuration
|
|
4
|
+
*/
|
|
5
|
+
export interface S3ClientConfig {
|
|
6
|
+
/** AWS region */
|
|
7
|
+
region: string;
|
|
8
|
+
/** AWS credentials (optional - uses default credential chain if not provided) */
|
|
9
|
+
credentials?: {
|
|
10
|
+
accessKeyId: string;
|
|
11
|
+
secretAccessKey: string;
|
|
12
|
+
sessionToken?: string;
|
|
13
|
+
};
|
|
14
|
+
/** Custom endpoint URL (for S3-compatible services like MinIO) */
|
|
15
|
+
endpoint?: string;
|
|
16
|
+
/** Force path style URLs (required for some S3-compatible services) */
|
|
17
|
+
forcePathStyle?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* S3 instance wrapper
|
|
21
|
+
*/
|
|
22
|
+
export interface S3Instance {
|
|
23
|
+
client: S3Client;
|
|
24
|
+
region: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Options for upload operations
|
|
28
|
+
*/
|
|
29
|
+
export interface UploadOptions {
|
|
30
|
+
/** Content type of the file */
|
|
31
|
+
contentType?: string;
|
|
32
|
+
/** Cache-Control header */
|
|
33
|
+
cacheControl?: string;
|
|
34
|
+
/** Content-Disposition header */
|
|
35
|
+
contentDisposition?: string;
|
|
36
|
+
/** Custom metadata */
|
|
37
|
+
metadata?: Record<string, string>;
|
|
38
|
+
/** Access control list */
|
|
39
|
+
acl?: 'private' | 'public-read' | 'public-read-write' | 'authenticated-read';
|
|
40
|
+
/** Server-side encryption */
|
|
41
|
+
serverSideEncryption?: 'AES256' | 'aws:kms';
|
|
42
|
+
/** Storage class */
|
|
43
|
+
storageClass?: 'STANDARD' | 'REDUCED_REDUNDANCY' | 'STANDARD_IA' | 'ONEZONE_IA' | 'INTELLIGENT_TIERING' | 'GLACIER' | 'DEEP_ARCHIVE';
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Options for download operations
|
|
47
|
+
*/
|
|
48
|
+
export interface DownloadOptions {
|
|
49
|
+
/** Byte range to download */
|
|
50
|
+
range?: string;
|
|
51
|
+
/** Only return if modified since this date */
|
|
52
|
+
ifModifiedSince?: Date;
|
|
53
|
+
/** Only return if not modified since this date */
|
|
54
|
+
ifUnmodifiedSince?: Date;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Options for presigned URL generation
|
|
58
|
+
*/
|
|
59
|
+
export interface PresignedUrlOptions {
|
|
60
|
+
/** URL expiration in seconds */
|
|
61
|
+
expiresIn?: number;
|
|
62
|
+
/** Content type for upload URLs */
|
|
63
|
+
contentType?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Options for listing objects
|
|
67
|
+
*/
|
|
68
|
+
export interface ListObjectsOptions {
|
|
69
|
+
/** Prefix to filter objects */
|
|
70
|
+
prefix?: string;
|
|
71
|
+
/** Delimiter for grouping */
|
|
72
|
+
delimiter?: string;
|
|
73
|
+
/** Maximum number of keys to return */
|
|
74
|
+
maxKeys?: number;
|
|
75
|
+
/** Continuation token for pagination */
|
|
76
|
+
continuationToken?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* S3 object metadata
|
|
80
|
+
*/
|
|
81
|
+
export interface S3ObjectMetadata {
|
|
82
|
+
key: string;
|
|
83
|
+
size?: number;
|
|
84
|
+
lastModified?: Date;
|
|
85
|
+
etag?: string;
|
|
86
|
+
storageClass?: string;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/aws/s3/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,iBAAiB;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,WAAW,CAAC,EAAE;QACZ,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;QACxB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,+BAA+B;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2BAA2B;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,sBAAsB;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,0BAA0B;IAC1B,GAAG,CAAC,EAAE,SAAS,GAAG,aAAa,GAAG,mBAAmB,GAAG,oBAAoB,CAAC;IAC7E,6BAA6B;IAC7B,oBAAoB,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5C,oBAAoB;IACpB,YAAY,CAAC,EAAE,UAAU,GAAG,oBAAoB,GAAG,aAAa,GAAG,YAAY,GAAG,qBAAqB,GAAG,SAAS,GAAG,cAAc,CAAC;CACtI;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,eAAe,CAAC,EAAE,IAAI,CAAC;IACvB,kDAAkD;IAClD,iBAAiB,CAAC,EAAE,IAAI,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { RedisInstance } from '../redis/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* API response cache using Redis
|
|
4
|
+
* Caches API call results with configurable TTL
|
|
5
|
+
*/
|
|
6
|
+
export declare class ApiCache<T = unknown> {
|
|
7
|
+
private redis;
|
|
8
|
+
private cacheType;
|
|
9
|
+
private apiFunction;
|
|
10
|
+
private cacheLength;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an ApiCache instance
|
|
13
|
+
* @param redis Redis instance for caching
|
|
14
|
+
* @param cacheType Type identifier for cache keys
|
|
15
|
+
* @param apiFunction Function to call when cache misses
|
|
16
|
+
* @param cacheLength TTL in seconds (default: 1 hour)
|
|
17
|
+
*/
|
|
18
|
+
constructor(redis: RedisInstance, cacheType: string, apiFunction: () => Promise<T>, cacheLength?: number);
|
|
19
|
+
/**
|
|
20
|
+
* Gets cached value or fetches from API
|
|
21
|
+
* @param cacheId Unique identifier for this cache entry
|
|
22
|
+
* @param parse Whether to JSON parse the cached value
|
|
23
|
+
* @returns Cached or fresh data
|
|
24
|
+
*/
|
|
25
|
+
getCached(cacheId: string, parse?: boolean): Promise<T | string | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Forces a refresh of the cached value
|
|
28
|
+
* @param cacheId Unique identifier for this cache entry
|
|
29
|
+
* @param parse Whether to JSON parse the cached value
|
|
30
|
+
* @returns Fresh data from API
|
|
31
|
+
*/
|
|
32
|
+
refreshCached(cacheId: string, parse?: boolean): Promise<T | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Deletes a cached entry
|
|
35
|
+
* @param cacheId Unique identifier for this cache entry
|
|
36
|
+
*/
|
|
37
|
+
deleteCached(cacheId: string): Promise<void>;
|
|
38
|
+
private getAndCache;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=api-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-cache.d.ts","sourceRoot":"","sources":["../../src/caches/api-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKvD;;;GAGG;AACH,qBAAa,QAAQ,CAAC,CAAC,GAAG,OAAO;IAC/B,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAAmB;IACtC,OAAO,CAAC,WAAW,CAAS;IAE5B;;;;;;OAMG;gBACS,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,GAAE,MAAa;IAO9G;;;;;OAKG;IACU,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,OAAc,GAAG,OAAO,CAAC,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IAU1F;;;;;OAKG;IACU,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,OAAc,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAIrF;;;OAGG;IACU,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAI3C,WAAW;CAa1B"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { get, set, del } from '../redis/operations/standard.js';
|
|
2
|
+
const generateKey = (type, cacheId) => `api-cache:${type}:${cacheId}`;
|
|
3
|
+
/**
|
|
4
|
+
* API response cache using Redis
|
|
5
|
+
* Caches API call results with configurable TTL
|
|
6
|
+
*/
|
|
7
|
+
export class ApiCache {
|
|
8
|
+
redis;
|
|
9
|
+
cacheType;
|
|
10
|
+
apiFunction;
|
|
11
|
+
cacheLength;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an ApiCache instance
|
|
14
|
+
* @param redis Redis instance for caching
|
|
15
|
+
* @param cacheType Type identifier for cache keys
|
|
16
|
+
* @param apiFunction Function to call when cache misses
|
|
17
|
+
* @param cacheLength TTL in seconds (default: 1 hour)
|
|
18
|
+
*/
|
|
19
|
+
constructor(redis, cacheType, apiFunction, cacheLength = 3600) {
|
|
20
|
+
this.redis = redis;
|
|
21
|
+
this.cacheType = cacheType;
|
|
22
|
+
this.apiFunction = apiFunction;
|
|
23
|
+
this.cacheLength = cacheLength;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Gets cached value or fetches from API
|
|
27
|
+
* @param cacheId Unique identifier for this cache entry
|
|
28
|
+
* @param parse Whether to JSON parse the cached value
|
|
29
|
+
* @returns Cached or fresh data
|
|
30
|
+
*/
|
|
31
|
+
async getCached(cacheId, parse = true) {
|
|
32
|
+
const cachedObject = await get(this.redis, generateKey(this.cacheType, cacheId));
|
|
33
|
+
if (cachedObject) {
|
|
34
|
+
return parse ? JSON.parse(cachedObject) : cachedObject;
|
|
35
|
+
}
|
|
36
|
+
return this.getAndCache(cacheId, parse);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Forces a refresh of the cached value
|
|
40
|
+
* @param cacheId Unique identifier for this cache entry
|
|
41
|
+
* @param parse Whether to JSON parse the cached value
|
|
42
|
+
* @returns Fresh data from API
|
|
43
|
+
*/
|
|
44
|
+
async refreshCached(cacheId, parse = true) {
|
|
45
|
+
return this.getAndCache(cacheId, parse);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Deletes a cached entry
|
|
49
|
+
* @param cacheId Unique identifier for this cache entry
|
|
50
|
+
*/
|
|
51
|
+
async deleteCached(cacheId) {
|
|
52
|
+
await del(this.redis, generateKey(this.cacheType, cacheId));
|
|
53
|
+
}
|
|
54
|
+
async getAndCache(cacheId, parse) {
|
|
55
|
+
const record = await this.apiFunction();
|
|
56
|
+
if (record) {
|
|
57
|
+
const data = parse ? JSON.stringify(record) : record;
|
|
58
|
+
await set(this.redis, generateKey(this.cacheType, cacheId), data, {
|
|
59
|
+
ttl: this.cacheLength
|
|
60
|
+
});
|
|
61
|
+
return record;
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { RedisInstance } from '../redis/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Database query cache using Redis
|
|
4
|
+
* Caches database query results with configurable TTL
|
|
5
|
+
*/
|
|
6
|
+
export declare class DatabaseCache<T = unknown> {
|
|
7
|
+
private redis;
|
|
8
|
+
private cacheType;
|
|
9
|
+
private databaseFunction;
|
|
10
|
+
private cacheLength;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a DatabaseCache instance
|
|
13
|
+
* @param redis Redis instance for caching
|
|
14
|
+
* @param cacheType Type identifier for cache keys
|
|
15
|
+
* @param databaseFunction Function to call when cache misses
|
|
16
|
+
* @param cacheLength TTL in seconds (default: 1 hour)
|
|
17
|
+
*/
|
|
18
|
+
constructor(redis: RedisInstance, cacheType: string, databaseFunction: () => Promise<T>, cacheLength?: number);
|
|
19
|
+
/**
|
|
20
|
+
* Gets cached value or fetches from database
|
|
21
|
+
* @param cacheId Unique identifier for this cache entry
|
|
22
|
+
* @param parse Whether to JSON parse the cached value
|
|
23
|
+
* @returns Cached or fresh data
|
|
24
|
+
*/
|
|
25
|
+
getCached(cacheId: string, parse?: boolean): Promise<T | string | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Forces a refresh of the cached value
|
|
28
|
+
* @param cacheId Unique identifier for this cache entry
|
|
29
|
+
* @param parse Whether to JSON parse the cached value
|
|
30
|
+
* @returns Fresh data from database
|
|
31
|
+
*/
|
|
32
|
+
refreshCached(cacheId: string, parse?: boolean): Promise<T | string | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Deletes a cached entry
|
|
35
|
+
* @param cacheId Unique identifier for this cache entry
|
|
36
|
+
*/
|
|
37
|
+
deleteCached(cacheId: string): Promise<void>;
|
|
38
|
+
private getAndCache;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=database-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-cache.d.ts","sourceRoot":"","sources":["../../src/caches/database-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKvD;;;GAGG;AACH,qBAAa,aAAa,CAAC,CAAC,GAAG,OAAO;IACpC,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,WAAW,CAAS;IAE5B;;;;;;OAMG;gBACS,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,GAAE,MAAa;IAOnH;;;;;OAKG;IACU,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,OAAc,GAAG,OAAO,CAAC,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IAU1F;;;;;OAKG;IACU,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,OAAc,GAAG,OAAO,CAAC,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IAI9F;;;OAGG;IACU,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAI3C,WAAW;CAa1B"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { get, set, del } from '../redis/operations/standard.js';
|
|
2
|
+
const generateKey = (type, cacheId) => `database-cache:${type}:${cacheId}`;
|
|
3
|
+
/**
|
|
4
|
+
* Database query cache using Redis
|
|
5
|
+
* Caches database query results with configurable TTL
|
|
6
|
+
*/
|
|
7
|
+
export class DatabaseCache {
|
|
8
|
+
redis;
|
|
9
|
+
cacheType;
|
|
10
|
+
databaseFunction;
|
|
11
|
+
cacheLength;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a DatabaseCache instance
|
|
14
|
+
* @param redis Redis instance for caching
|
|
15
|
+
* @param cacheType Type identifier for cache keys
|
|
16
|
+
* @param databaseFunction Function to call when cache misses
|
|
17
|
+
* @param cacheLength TTL in seconds (default: 1 hour)
|
|
18
|
+
*/
|
|
19
|
+
constructor(redis, cacheType, databaseFunction, cacheLength = 3600) {
|
|
20
|
+
this.redis = redis;
|
|
21
|
+
this.cacheType = cacheType;
|
|
22
|
+
this.databaseFunction = databaseFunction;
|
|
23
|
+
this.cacheLength = cacheLength;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Gets cached value or fetches from database
|
|
27
|
+
* @param cacheId Unique identifier for this cache entry
|
|
28
|
+
* @param parse Whether to JSON parse the cached value
|
|
29
|
+
* @returns Cached or fresh data
|
|
30
|
+
*/
|
|
31
|
+
async getCached(cacheId, parse = true) {
|
|
32
|
+
const cachedObject = await get(this.redis, generateKey(this.cacheType, cacheId));
|
|
33
|
+
if (cachedObject) {
|
|
34
|
+
return parse ? JSON.parse(cachedObject) : cachedObject;
|
|
35
|
+
}
|
|
36
|
+
return this.getAndCache(cacheId, parse);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Forces a refresh of the cached value
|
|
40
|
+
* @param cacheId Unique identifier for this cache entry
|
|
41
|
+
* @param parse Whether to JSON parse the cached value
|
|
42
|
+
* @returns Fresh data from database
|
|
43
|
+
*/
|
|
44
|
+
async refreshCached(cacheId, parse = true) {
|
|
45
|
+
return this.getAndCache(cacheId, parse);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Deletes a cached entry
|
|
49
|
+
* @param cacheId Unique identifier for this cache entry
|
|
50
|
+
*/
|
|
51
|
+
async deleteCached(cacheId) {
|
|
52
|
+
await del(this.redis, generateKey(this.cacheType, cacheId));
|
|
53
|
+
}
|
|
54
|
+
async getAndCache(cacheId, parse) {
|
|
55
|
+
const record = await this.databaseFunction();
|
|
56
|
+
if (record) {
|
|
57
|
+
const data = parse ? JSON.stringify(record) : record;
|
|
58
|
+
await set(this.redis, generateKey(this.cacheType, cacheId), data, {
|
|
59
|
+
ttl: this.cacheLength
|
|
60
|
+
});
|
|
61
|
+
return record;
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/caches/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface LoadEnvOptions {
|
|
2
|
+
path?: string;
|
|
3
|
+
override?: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Loads environment variables from .env file
|
|
7
|
+
* @param options Configuration options for loading env
|
|
8
|
+
* @returns Object with parsed env variables or error
|
|
9
|
+
*/
|
|
10
|
+
export declare function loadEnv(options?: LoadEnvOptions): {
|
|
11
|
+
success: boolean;
|
|
12
|
+
error?: Error;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Gets an environment variable with optional default
|
|
16
|
+
* @param key The environment variable key
|
|
17
|
+
* @param defaultValue Optional default value if not set
|
|
18
|
+
* @returns The environment variable value or default
|
|
19
|
+
*/
|
|
20
|
+
export declare function getEnv(key: string, defaultValue?: string): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Gets a required environment variable, throws if not set
|
|
23
|
+
* @param key The environment variable key
|
|
24
|
+
* @returns The environment variable value
|
|
25
|
+
* @throws Error if the environment variable is not set
|
|
26
|
+
*/
|
|
27
|
+
export declare function requireEnv(key: string): string;
|
|
28
|
+
//# sourceMappingURL=env-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-loader.d.ts","sourceRoot":"","sources":["../../src/config/env-loader.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAWzF;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE7E;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM9C"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { config as dotenvConfig } from 'dotenv';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Loads environment variables from .env file
|
|
5
|
+
* @param options Configuration options for loading env
|
|
6
|
+
* @returns Object with parsed env variables or error
|
|
7
|
+
*/
|
|
8
|
+
export function loadEnv(options = {}) {
|
|
9
|
+
const result = dotenvConfig({
|
|
10
|
+
path: options.path ? resolve(options.path) : undefined,
|
|
11
|
+
override: options.override ?? false
|
|
12
|
+
});
|
|
13
|
+
if (result.error) {
|
|
14
|
+
return { success: false, error: result.error };
|
|
15
|
+
}
|
|
16
|
+
return { success: true };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Gets an environment variable with optional default
|
|
20
|
+
* @param key The environment variable key
|
|
21
|
+
* @param defaultValue Optional default value if not set
|
|
22
|
+
* @returns The environment variable value or default
|
|
23
|
+
*/
|
|
24
|
+
export function getEnv(key, defaultValue) {
|
|
25
|
+
return process.env[key] ?? defaultValue;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Gets a required environment variable, throws if not set
|
|
29
|
+
* @param key The environment variable key
|
|
30
|
+
* @returns The environment variable value
|
|
31
|
+
* @throws Error if the environment variable is not set
|
|
32
|
+
*/
|
|
33
|
+
export function requireEnv(key) {
|
|
34
|
+
const value = process.env[key];
|
|
35
|
+
if (value === undefined) {
|
|
36
|
+
throw new Error(`Required environment variable ${key} is not set`);
|
|
37
|
+
}
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { loadEnv, getEnv, requireEnv } from './env-loader.js';
|
|
2
|
+
export type { LoadEnvOptions } from './env-loader.js';
|
|
3
|
+
export { DatabaseConfigSchema, RedisConfigSchema, RedisClusterConfigSchema, RabbitMQConfigSchema, LoggingConfigSchema, validateConfig, safeValidateConfig } from './schemas.js';
|
|
4
|
+
export type { DatabaseConfig, RedisConfig, RedisClusterConfig, RabbitMQConfig, LoggingConfig } from './types.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC9D,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|