@elsikora/nestjs-crud-config 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 +21 -0
- package/README.md +633 -0
- package/dist/cjs/external/tslib/tslib.es6.js +43 -0
- package/dist/cjs/external/tslib/tslib.es6.js.map +1 -0
- package/dist/cjs/index.d.ts +13 -0
- package/dist/cjs/index.js +52 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/modules/config/config.module.d.ts +13 -0
- package/dist/cjs/modules/config/config.module.js +230 -0
- package/dist/cjs/modules/config/config.module.js.map +1 -0
- package/dist/cjs/modules/config/config.service.d.ts +50 -0
- package/dist/cjs/modules/config/config.service.js +355 -0
- package/dist/cjs/modules/config/config.service.js.map +1 -0
- package/dist/cjs/modules/config/data/controller.d.ts +10 -0
- package/dist/cjs/modules/config/data/controller.js +76 -0
- package/dist/cjs/modules/config/data/controller.js.map +1 -0
- package/dist/cjs/modules/config/data/entity/entity.d.ts +20 -0
- package/dist/cjs/modules/config/data/entity/entity.js +158 -0
- package/dist/cjs/modules/config/data/entity/entity.js.map +1 -0
- package/dist/cjs/modules/config/data/entity/index.d.ts +1 -0
- package/dist/cjs/modules/config/data/event/before-insert.event.d.ts +20 -0
- package/dist/cjs/modules/config/data/event/before-insert.event.js +23 -0
- package/dist/cjs/modules/config/data/event/before-insert.event.js.map +1 -0
- package/dist/cjs/modules/config/data/event/index.d.ts +1 -0
- package/dist/cjs/modules/config/data/index.d.ts +6 -0
- package/dist/cjs/modules/config/data/interface/index.d.ts +1 -0
- package/dist/cjs/modules/config/data/interface/interface.d.ts +12 -0
- package/dist/cjs/modules/config/data/listener/before-insert.listener.d.ts +19 -0
- package/dist/cjs/modules/config/data/listener/before-insert.listener.js +59 -0
- package/dist/cjs/modules/config/data/listener/before-insert.listener.js.map +1 -0
- package/dist/cjs/modules/config/data/listener/index.d.ts +1 -0
- package/dist/cjs/modules/config/data/subscriber/before-insert.subscriber.d.ts +26 -0
- package/dist/cjs/modules/config/data/subscriber/before-insert.subscriber.js +74 -0
- package/dist/cjs/modules/config/data/subscriber/before-insert.subscriber.js.map +1 -0
- package/dist/cjs/modules/config/data/subscriber/index.d.ts +1 -0
- package/dist/cjs/modules/config/index.d.ts +9 -0
- package/dist/cjs/modules/config/interface/delete-options.interface.d.ts +22 -0
- package/dist/cjs/modules/config/interface/get-list-options.interface.d.ts +22 -0
- package/dist/cjs/modules/config/interface/get-options.interface.d.ts +30 -0
- package/dist/cjs/modules/config/interface/index.d.ts +4 -0
- package/dist/cjs/modules/config/interface/set-options.interface.d.ts +34 -0
- package/dist/cjs/modules/config/section/controller.d.ts +10 -0
- package/dist/cjs/modules/config/section/controller.js +46 -0
- package/dist/cjs/modules/config/section/controller.js.map +1 -0
- package/dist/cjs/modules/config/section/entity/entity.d.ts +14 -0
- package/dist/cjs/modules/config/section/entity/entity.js +96 -0
- package/dist/cjs/modules/config/section/entity/entity.js.map +1 -0
- package/dist/cjs/modules/config/section/entity/index.d.ts +1 -0
- package/dist/cjs/modules/config/section/index.d.ts +2 -0
- package/dist/cjs/modules/config/section/interface/index.d.ts +1 -0
- package/dist/cjs/modules/config/section/interface/interface.d.ts +7 -0
- package/dist/cjs/modules/config/type/index.d.ts +2 -0
- package/dist/cjs/modules/config/type/item.type.d.ts +1 -0
- package/dist/cjs/modules/config/type/type.d.ts +2 -0
- package/dist/cjs/package.json +8 -0
- package/dist/cjs/shared/constant/api-property.constant.d.ts +4 -0
- package/dist/cjs/shared/constant/api-property.constant.js +11 -0
- package/dist/cjs/shared/constant/api-property.constant.js.map +1 -0
- package/dist/cjs/shared/constant/config/data.constant.d.ts +7 -0
- package/dist/cjs/shared/constant/config/data.constant.js +17 -0
- package/dist/cjs/shared/constant/config/data.constant.js.map +1 -0
- package/dist/cjs/shared/constant/config/index.d.ts +2 -0
- package/dist/cjs/shared/constant/config/section.constant.d.ts +5 -0
- package/dist/cjs/shared/constant/config/section.constant.js +13 -0
- package/dist/cjs/shared/constant/config/section.constant.js.map +1 -0
- package/dist/cjs/shared/constant/crypto.constant.d.ts +7 -0
- package/dist/cjs/shared/constant/crypto.constant.js +17 -0
- package/dist/cjs/shared/constant/crypto.constant.js.map +1 -0
- package/dist/cjs/shared/constant/index.d.ts +4 -0
- package/dist/cjs/shared/constant/token.constant.d.ts +8 -0
- package/dist/cjs/shared/constant/token.constant.js +20 -0
- package/dist/cjs/shared/constant/token.constant.js.map +1 -0
- package/dist/cjs/shared/enum/environment.enum.d.ts +16 -0
- package/dist/cjs/shared/enum/environment.enum.js +20 -0
- package/dist/cjs/shared/enum/environment.enum.js.map +1 -0
- package/dist/cjs/shared/enum/index.d.ts +6 -0
- package/dist/cjs/shared/enum/instance-name.enum.d.ts +7 -0
- package/dist/cjs/shared/enum/instance-name.enum.js +11 -0
- package/dist/cjs/shared/enum/instance-name.enum.js.map +1 -0
- package/dist/cjs/shared/enum/service.enum.d.ts +220 -0
- package/dist/cjs/shared/enum/service.enum.js +224 -0
- package/dist/cjs/shared/enum/service.enum.js.map +1 -0
- package/dist/cjs/shared/index.d.ts +5 -0
- package/dist/cjs/shared/interface/config/async-module-properties.interface.d.ts +16 -0
- package/dist/cjs/shared/interface/config/cache-options.interface.d.ts +17 -0
- package/dist/cjs/shared/interface/config/config-data-entity-options.interface.d.ts +25 -0
- package/dist/cjs/shared/interface/config/controller-options.interface.d.ts +28 -0
- package/dist/cjs/shared/interface/config/encryption-options.interface.d.ts +13 -0
- package/dist/cjs/shared/interface/config/entity/data-options.interface.d.ts +25 -0
- package/dist/cjs/shared/interface/config/entity/index.d.ts +3 -0
- package/dist/cjs/shared/interface/config/entity/options.interface.d.ts +18 -0
- package/dist/cjs/shared/interface/config/entity/section-options.interface.d.ts +17 -0
- package/dist/cjs/shared/interface/config/index.d.ts +7 -0
- package/dist/cjs/shared/interface/config/options.interface.d.ts +37 -0
- package/dist/cjs/shared/interface/config/properties-factory.interface.d.ts +11 -0
- package/dist/cjs/shared/interface/index.d.ts +2 -0
- package/dist/cjs/shared/interface/utility/create-dynamic-entity/index.d.ts +2 -0
- package/dist/cjs/shared/interface/utility/create-dynamic-entity/options.interface.d.ts +15 -0
- package/dist/cjs/shared/interface/utility/create-dynamic-entity/relation-options.interface.d.ts +9 -0
- package/dist/cjs/shared/interface/utility/index.d.ts +1 -0
- package/dist/cjs/shared/type/dynamic-entity.type.d.ts +1 -0
- package/dist/cjs/shared/type/index.d.ts +1 -0
- package/dist/cjs/shared/utility/create-dynamic/entity.utility.d.ts +9 -0
- package/dist/cjs/shared/utility/create-dynamic/entity.utility.js +67 -0
- package/dist/cjs/shared/utility/create-dynamic/entity.utility.js.map +1 -0
- package/dist/cjs/shared/utility/create-dynamic/index.d.ts +2 -0
- package/dist/cjs/shared/utility/create-dynamic/service.utility.d.ts +9 -0
- package/dist/cjs/shared/utility/create-dynamic/service.utility.js +34 -0
- package/dist/cjs/shared/utility/create-dynamic/service.utility.js.map +1 -0
- package/dist/cjs/shared/utility/create-dynamic-entity.utility.d.ts +9 -0
- package/dist/cjs/shared/utility/create-dynamic-entity.utility.js +67 -0
- package/dist/cjs/shared/utility/create-dynamic-entity.utility.js.map +1 -0
- package/dist/cjs/shared/utility/crypto.utility.d.ts +27 -0
- package/dist/cjs/shared/utility/crypto.utility.js +72 -0
- package/dist/cjs/shared/utility/crypto.utility.js.map +1 -0
- package/dist/cjs/shared/utility/index.d.ts +3 -0
- package/dist/esm/external/tslib/tslib.es6.js +39 -0
- package/dist/esm/external/tslib/tslib.es6.js.map +1 -0
- package/dist/esm/index.d.ts +13 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/modules/config/config.module.d.ts +13 -0
- package/dist/esm/modules/config/config.module.js +230 -0
- package/dist/esm/modules/config/config.module.js.map +1 -0
- package/dist/esm/modules/config/config.service.d.ts +50 -0
- package/dist/esm/modules/config/config.service.js +355 -0
- package/dist/esm/modules/config/config.service.js.map +1 -0
- package/dist/esm/modules/config/data/controller.d.ts +10 -0
- package/dist/esm/modules/config/data/controller.js +74 -0
- package/dist/esm/modules/config/data/controller.js.map +1 -0
- package/dist/esm/modules/config/data/entity/entity.d.ts +20 -0
- package/dist/esm/modules/config/data/entity/entity.js +156 -0
- package/dist/esm/modules/config/data/entity/entity.js.map +1 -0
- package/dist/esm/modules/config/data/entity/index.d.ts +1 -0
- package/dist/esm/modules/config/data/event/before-insert.event.d.ts +20 -0
- package/dist/esm/modules/config/data/event/before-insert.event.js +21 -0
- package/dist/esm/modules/config/data/event/before-insert.event.js.map +1 -0
- package/dist/esm/modules/config/data/event/index.d.ts +1 -0
- package/dist/esm/modules/config/data/index.d.ts +6 -0
- package/dist/esm/modules/config/data/interface/index.d.ts +1 -0
- package/dist/esm/modules/config/data/interface/interface.d.ts +12 -0
- package/dist/esm/modules/config/data/listener/before-insert.listener.d.ts +19 -0
- package/dist/esm/modules/config/data/listener/before-insert.listener.js +59 -0
- package/dist/esm/modules/config/data/listener/before-insert.listener.js.map +1 -0
- package/dist/esm/modules/config/data/listener/index.d.ts +1 -0
- package/dist/esm/modules/config/data/subscriber/before-insert.subscriber.d.ts +26 -0
- package/dist/esm/modules/config/data/subscriber/before-insert.subscriber.js +74 -0
- package/dist/esm/modules/config/data/subscriber/before-insert.subscriber.js.map +1 -0
- package/dist/esm/modules/config/data/subscriber/index.d.ts +1 -0
- package/dist/esm/modules/config/index.d.ts +9 -0
- package/dist/esm/modules/config/interface/delete-options.interface.d.ts +22 -0
- package/dist/esm/modules/config/interface/get-list-options.interface.d.ts +22 -0
- package/dist/esm/modules/config/interface/get-options.interface.d.ts +30 -0
- package/dist/esm/modules/config/interface/index.d.ts +4 -0
- package/dist/esm/modules/config/interface/set-options.interface.d.ts +34 -0
- package/dist/esm/modules/config/section/controller.d.ts +10 -0
- package/dist/esm/modules/config/section/controller.js +44 -0
- package/dist/esm/modules/config/section/controller.js.map +1 -0
- package/dist/esm/modules/config/section/entity/entity.d.ts +14 -0
- package/dist/esm/modules/config/section/entity/entity.js +94 -0
- package/dist/esm/modules/config/section/entity/entity.js.map +1 -0
- package/dist/esm/modules/config/section/entity/index.d.ts +1 -0
- package/dist/esm/modules/config/section/index.d.ts +2 -0
- package/dist/esm/modules/config/section/interface/index.d.ts +1 -0
- package/dist/esm/modules/config/section/interface/interface.d.ts +7 -0
- package/dist/esm/modules/config/type/index.d.ts +2 -0
- package/dist/esm/modules/config/type/item.type.d.ts +1 -0
- package/dist/esm/modules/config/type/type.d.ts +2 -0
- package/dist/esm/package.json +8 -0
- package/dist/esm/shared/constant/api-property.constant.d.ts +4 -0
- package/dist/esm/shared/constant/api-property.constant.js +9 -0
- package/dist/esm/shared/constant/api-property.constant.js.map +1 -0
- package/dist/esm/shared/constant/config/data.constant.d.ts +7 -0
- package/dist/esm/shared/constant/config/data.constant.js +15 -0
- package/dist/esm/shared/constant/config/data.constant.js.map +1 -0
- package/dist/esm/shared/constant/config/index.d.ts +2 -0
- package/dist/esm/shared/constant/config/section.constant.d.ts +5 -0
- package/dist/esm/shared/constant/config/section.constant.js +11 -0
- package/dist/esm/shared/constant/config/section.constant.js.map +1 -0
- package/dist/esm/shared/constant/crypto.constant.d.ts +7 -0
- package/dist/esm/shared/constant/crypto.constant.js +15 -0
- package/dist/esm/shared/constant/crypto.constant.js.map +1 -0
- package/dist/esm/shared/constant/index.d.ts +4 -0
- package/dist/esm/shared/constant/token.constant.d.ts +8 -0
- package/dist/esm/shared/constant/token.constant.js +18 -0
- package/dist/esm/shared/constant/token.constant.js.map +1 -0
- package/dist/esm/shared/enum/environment.enum.d.ts +16 -0
- package/dist/esm/shared/enum/environment.enum.js +20 -0
- package/dist/esm/shared/enum/environment.enum.js.map +1 -0
- package/dist/esm/shared/enum/index.d.ts +6 -0
- package/dist/esm/shared/enum/instance-name.enum.d.ts +7 -0
- package/dist/esm/shared/enum/instance-name.enum.js +11 -0
- package/dist/esm/shared/enum/instance-name.enum.js.map +1 -0
- package/dist/esm/shared/enum/service.enum.d.ts +220 -0
- package/dist/esm/shared/enum/service.enum.js +224 -0
- package/dist/esm/shared/enum/service.enum.js.map +1 -0
- package/dist/esm/shared/index.d.ts +5 -0
- package/dist/esm/shared/interface/config/async-module-properties.interface.d.ts +16 -0
- package/dist/esm/shared/interface/config/cache-options.interface.d.ts +17 -0
- package/dist/esm/shared/interface/config/config-data-entity-options.interface.d.ts +25 -0
- package/dist/esm/shared/interface/config/controller-options.interface.d.ts +28 -0
- package/dist/esm/shared/interface/config/encryption-options.interface.d.ts +13 -0
- package/dist/esm/shared/interface/config/entity/data-options.interface.d.ts +25 -0
- package/dist/esm/shared/interface/config/entity/index.d.ts +3 -0
- package/dist/esm/shared/interface/config/entity/options.interface.d.ts +18 -0
- package/dist/esm/shared/interface/config/entity/section-options.interface.d.ts +17 -0
- package/dist/esm/shared/interface/config/index.d.ts +7 -0
- package/dist/esm/shared/interface/config/options.interface.d.ts +37 -0
- package/dist/esm/shared/interface/config/properties-factory.interface.d.ts +11 -0
- package/dist/esm/shared/interface/index.d.ts +2 -0
- package/dist/esm/shared/interface/utility/create-dynamic-entity/index.d.ts +2 -0
- package/dist/esm/shared/interface/utility/create-dynamic-entity/options.interface.d.ts +15 -0
- package/dist/esm/shared/interface/utility/create-dynamic-entity/relation-options.interface.d.ts +9 -0
- package/dist/esm/shared/interface/utility/index.d.ts +1 -0
- package/dist/esm/shared/type/dynamic-entity.type.d.ts +1 -0
- package/dist/esm/shared/type/index.d.ts +1 -0
- package/dist/esm/shared/utility/create-dynamic/entity.utility.d.ts +9 -0
- package/dist/esm/shared/utility/create-dynamic/entity.utility.js +65 -0
- package/dist/esm/shared/utility/create-dynamic/entity.utility.js.map +1 -0
- package/dist/esm/shared/utility/create-dynamic/index.d.ts +2 -0
- package/dist/esm/shared/utility/create-dynamic/service.utility.d.ts +9 -0
- package/dist/esm/shared/utility/create-dynamic/service.utility.js +32 -0
- package/dist/esm/shared/utility/create-dynamic/service.utility.js.map +1 -0
- package/dist/esm/shared/utility/create-dynamic-entity.utility.d.ts +9 -0
- package/dist/esm/shared/utility/create-dynamic-entity.utility.js +65 -0
- package/dist/esm/shared/utility/create-dynamic-entity.utility.js.map +1 -0
- package/dist/esm/shared/utility/crypto.utility.d.ts +27 -0
- package/dist/esm/shared/utility/crypto.utility.js +72 -0
- package/dist/esm/shared/utility/crypto.utility.js.map +1 -0
- package/dist/esm/shared/utility/index.d.ts +3 -0
- package/package.json +115 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ElsiKora
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,633 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://6jft62zmy9nx2oea.public.blob.vercel-storage.com/nestjs-crud-config-dCbe8myqKpk3fxrTwBFBVCkKaz399M.png" width="500" alt="project-logo">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">NestJS CRUD Config 🚀</h1>
|
|
6
|
+
<p align="center"><em>Database-backed configuration management for NestJS applications with full CRUD capabilities</em></p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a aria-label="ElsiKora logo" href="https://elsikora.com">
|
|
10
|
+
<img src="https://img.shields.io/badge/MADE%20BY%20ElsiKora-333333.svg?style=for-the-badge" alt="ElsiKora">
|
|
11
|
+
</a> <img src="https://img.shields.io/badge/TypeScript-3178C6.svg?style=for-the-badge&logo=typescript&logoColor=white" alt="TypeScript"> <img src="https://img.shields.io/badge/NestJS-E0234E.svg?style=for-the-badge&logo=nestjs&logoColor=white" alt="NestJS"> <img src="https://img.shields.io/badge/Node.js-339933.svg?style=for-the-badge&logo=node.js&logoColor=white" alt="Node.js"> <img src="https://img.shields.io/badge/PostgreSQL-4169E1.svg?style=for-the-badge&logo=postgresql&logoColor=white" alt="PostgreSQL"> <img src="https://img.shields.io/badge/MySQL-4479A1.svg?style=for-the-badge&logo=mysql&logoColor=white" alt="MySQL"> <img src="https://img.shields.io/badge/SQLite-003B57.svg?style=for-the-badge&logo=sqlite&logoColor=white" alt="SQLite"> <img src="https://img.shields.io/badge/MongoDB-47A248.svg?style=for-the-badge&logo=mongodb&logoColor=white" alt="MongoDB"> <img src="https://img.shields.io/badge/Swagger-85EA2D.svg?style=for-the-badge&logo=swagger&logoColor=black" alt="Swagger">
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## 📚 Table of Contents
|
|
16
|
+
- [Description](#-description)
|
|
17
|
+
- [Features](#-features)
|
|
18
|
+
- [Installation](#-installation)
|
|
19
|
+
- [Usage](#-usage)
|
|
20
|
+
- [API Documentation](#-api-documentation)
|
|
21
|
+
- [Database Schema](#-database-schema)
|
|
22
|
+
- [Advanced Configuration](#-advanced-configuration)
|
|
23
|
+
- [Roadmap](#-roadmap)
|
|
24
|
+
- [FAQ](#-faq)
|
|
25
|
+
- [License](#-license)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## 📖 Description
|
|
29
|
+
|
|
30
|
+
NestJS CRUD Config is a powerful configuration management module that revolutionizes how NestJS applications handle configuration data. Unlike traditional environment variable approaches, this library stores configuration in a database with full CRUD operations, making it perfect for dynamic configuration management across multiple environments and services.
|
|
31
|
+
|
|
32
|
+
The module provides hierarchical organization through sections and data entries, supports optional AES-256-GCM encryption for sensitive values, and includes automatic REST API endpoints for configuration management. Built with TypeScript-first design and leveraging the NestJS CRUD Automator for automatic API generation, it features dynamic entity creation at runtime, comprehensive event-driven architecture, and intelligent caching.
|
|
33
|
+
|
|
34
|
+
Whether you're managing API keys across different environments, storing feature flags, or maintaining application settings that need to change without redeployment, this module provides a robust, secure, and scalable solution for microservice architectures, multi-tenant applications, and any system requiring centralized, database-backed configuration management with real-time updates.
|
|
35
|
+
|
|
36
|
+
## 🚀 Features
|
|
37
|
+
|
|
38
|
+
- **🗄️ Database-backed configuration storage** - Store configuration in any TypeORM-supported database for persistence and scalability
|
|
39
|
+
- **🏗️ Dynamic entity creation** - Entities are created at runtime with customizable table names, field lengths, and constraints
|
|
40
|
+
- **📊 Hierarchical organization** - Organize configuration using sections and data entries for better structure and management
|
|
41
|
+
- **🔐 AES-256-GCM encryption support** - Protect sensitive configuration values with built-in encryption using industry-standard algorithms
|
|
42
|
+
- **🌍 Multi-environment support** - Manage configurations across development, staging, and production environments seamlessly
|
|
43
|
+
- **⚡ Full CRUD operations** - Complete Create, Read, Update, Delete operations with automatic REST API endpoints
|
|
44
|
+
- **📚 Automatic Swagger documentation** - Generated OpenAPI documentation for all configuration endpoints
|
|
45
|
+
- **🎯 TypeScript-first design** - Full type safety with comprehensive interfaces and type definitions
|
|
46
|
+
- **🚀 NestJS CRUD Automator integration** - Leverages advanced CRUD automation for controllers and services
|
|
47
|
+
- **💾 Intelligent caching** - Built-in caching support with configurable TTL and cache size limits
|
|
48
|
+
- **🔄 Event-driven architecture** - Comprehensive event system with before/after hooks and TypeORM subscribers
|
|
49
|
+
- **🎛️ Highly customizable** - Configure table prefixes, field lengths, validation rules, and entity relationships
|
|
50
|
+
- **🚦 Flexible controller configuration** - Customize API paths, disable endpoints, or run in headless mode
|
|
51
|
+
- **🔧 Advanced CRUD customization** - Full control over routes, swagger documentation, and controller behavior
|
|
52
|
+
- **📦 Modular architecture** - Enable/disable features as needed for your use case
|
|
53
|
+
|
|
54
|
+
## 🛠 Installation
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Using npm
|
|
58
|
+
npm install @elsikora/nestjs-crud-config
|
|
59
|
+
|
|
60
|
+
# Using yarn
|
|
61
|
+
yarn add @elsikora/nestjs-crud-config
|
|
62
|
+
|
|
63
|
+
# Using pnpm
|
|
64
|
+
pnpm add @elsikora/nestjs-crud-config
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Prerequisites
|
|
68
|
+
|
|
69
|
+
Install the required peer dependencies:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm install @nestjs/common @nestjs/typeorm typeorm @elsikora/nestjs-crud-automator
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Database Support
|
|
76
|
+
|
|
77
|
+
This package works with any database supported by TypeORM:
|
|
78
|
+
- PostgreSQL
|
|
79
|
+
- MySQL/MariaDB
|
|
80
|
+
- SQLite
|
|
81
|
+
- Microsoft SQL Server
|
|
82
|
+
- Oracle
|
|
83
|
+
- MongoDB
|
|
84
|
+
- CockroachDB
|
|
85
|
+
|
|
86
|
+
## 💡 Usage
|
|
87
|
+
|
|
88
|
+
### Basic Setup
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
// app.module.ts
|
|
92
|
+
import { Module } from '@nestjs/common';
|
|
93
|
+
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
94
|
+
import { CrudConfigModule, TOKEN_CONSTANT } from '@elsikora/nestjs-crud-config';
|
|
95
|
+
|
|
96
|
+
@Module({
|
|
97
|
+
imports: [
|
|
98
|
+
// First register CrudConfigModule to create dynamic entities
|
|
99
|
+
CrudConfigModule.register({
|
|
100
|
+
environment: 'development',
|
|
101
|
+
isVerbose: true,
|
|
102
|
+
shouldAutoCreateSections: true,
|
|
103
|
+
|
|
104
|
+
// Cache configuration
|
|
105
|
+
cacheOptions: {
|
|
106
|
+
isEnabled: true,
|
|
107
|
+
maxCacheItems: 1000,
|
|
108
|
+
maxCacheTTL: 3600000, // 1 hour in milliseconds
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
// Encryption configuration
|
|
112
|
+
encryptionOptions: {
|
|
113
|
+
isEnabled: true,
|
|
114
|
+
encryptionKey: process.env.CONFIG_ENCRYPTION_KEY, // 32+ character key
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
// Controller configuration (optional)
|
|
118
|
+
controllersOptions: {
|
|
119
|
+
section: {
|
|
120
|
+
isEnabled: true,
|
|
121
|
+
properties: {
|
|
122
|
+
path: 'api/config/sections',
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
data: {
|
|
126
|
+
isEnabled: true,
|
|
127
|
+
properties: {
|
|
128
|
+
path: 'api/config/data',
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
// Entity customization
|
|
134
|
+
entityOptions: {
|
|
135
|
+
tablePrefix: 'app_',
|
|
136
|
+
configSection: {
|
|
137
|
+
tableName: 'config_sections',
|
|
138
|
+
maxNameLength: 128,
|
|
139
|
+
maxDescriptionLength: 512,
|
|
140
|
+
},
|
|
141
|
+
configData: {
|
|
142
|
+
tableName: 'config_data',
|
|
143
|
+
maxValueLength: 8192,
|
|
144
|
+
maxEnvironmentLength: 64,
|
|
145
|
+
maxNameLength: 128,
|
|
146
|
+
maxDescriptionLength: 512,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
}),
|
|
150
|
+
|
|
151
|
+
// Then register TypeORM with dynamic entities using registerAsync
|
|
152
|
+
TypeOrmModule.forRootAsync({
|
|
153
|
+
imports: [CrudConfigModule],
|
|
154
|
+
inject: [
|
|
155
|
+
TOKEN_CONSTANT.CONFIG_SECTION_ENTITY,
|
|
156
|
+
TOKEN_CONSTANT.CONFIG_DATA_ENTITY,
|
|
157
|
+
],
|
|
158
|
+
useFactory: async (sectionEntity, dataEntity) => ({
|
|
159
|
+
type: 'postgres',
|
|
160
|
+
host: 'localhost',
|
|
161
|
+
port: 5432,
|
|
162
|
+
username: 'postgres',
|
|
163
|
+
password: 'postgres',
|
|
164
|
+
database: 'config_db',
|
|
165
|
+
entities: [
|
|
166
|
+
// Your other entities
|
|
167
|
+
// UserEntity, ProductEntity, etc.
|
|
168
|
+
|
|
169
|
+
// Dynamic entities from CrudConfigModule
|
|
170
|
+
sectionEntity,
|
|
171
|
+
dataEntity,
|
|
172
|
+
],
|
|
173
|
+
synchronize: true,
|
|
174
|
+
}),
|
|
175
|
+
}),
|
|
176
|
+
],
|
|
177
|
+
})
|
|
178
|
+
export class AppModule {}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Using the Configuration Service
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
// config.service.ts
|
|
185
|
+
import { Injectable } from '@nestjs/common';
|
|
186
|
+
import { CrudConfigService } from '@elsikora/nestjs-crud-config';
|
|
187
|
+
|
|
188
|
+
@Injectable()
|
|
189
|
+
export class MyConfigService {
|
|
190
|
+
constructor(
|
|
191
|
+
private readonly configService: CrudConfigService,
|
|
192
|
+
) {}
|
|
193
|
+
|
|
194
|
+
async setupApplicationConfig() {
|
|
195
|
+
// Set a configuration value
|
|
196
|
+
await this.configService.set({
|
|
197
|
+
section: 'api-settings',
|
|
198
|
+
name: 'API_KEY',
|
|
199
|
+
value: 'my-secret-api-key',
|
|
200
|
+
description: 'Production API key',
|
|
201
|
+
environment: 'production',
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// Retrieve configuration by section and name
|
|
205
|
+
const apiConfig = await this.configService.get({
|
|
206
|
+
section: 'api-settings',
|
|
207
|
+
name: 'API_KEY',
|
|
208
|
+
environment: 'production',
|
|
209
|
+
shouldLoadSectionInfo: true,
|
|
210
|
+
useCache: true,
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
console.log('API Configuration:', apiConfig);
|
|
214
|
+
// apiConfig.value will be automatically decrypted if it was encrypted
|
|
215
|
+
|
|
216
|
+
return apiConfig;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
async getConfigurationList() {
|
|
220
|
+
// Get all configurations in a section
|
|
221
|
+
const configs = await this.configService.getList({
|
|
222
|
+
section: 'api-settings',
|
|
223
|
+
environment: 'production',
|
|
224
|
+
useCache: true,
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
return configs;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
async deleteConfiguration() {
|
|
231
|
+
// Delete a configuration
|
|
232
|
+
await this.configService.delete({
|
|
233
|
+
section: 'api-settings',
|
|
234
|
+
name: 'API_KEY',
|
|
235
|
+
environment: 'production',
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Async Module Registration
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
// app.module.ts
|
|
245
|
+
import { Module } from '@nestjs/common';
|
|
246
|
+
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
247
|
+
import { CrudConfigModule } from '@elsikora/nestjs-crud-config';
|
|
248
|
+
|
|
249
|
+
@Module({
|
|
250
|
+
imports: [
|
|
251
|
+
ConfigModule.forRoot(),
|
|
252
|
+
CrudConfigModule.registerAsync({
|
|
253
|
+
imports: [ConfigModule],
|
|
254
|
+
inject: [ConfigService],
|
|
255
|
+
useFactory: async (configService: ConfigService) => ({
|
|
256
|
+
environment: configService.get('NODE_ENV', 'development'),
|
|
257
|
+
isVerbose: configService.get('VERBOSE', false),
|
|
258
|
+
encryptionOptions: {
|
|
259
|
+
isEnabled: true,
|
|
260
|
+
encryptionKey: configService.get('ENCRYPTION_KEY'),
|
|
261
|
+
},
|
|
262
|
+
cacheOptions: {
|
|
263
|
+
isEnabled: true,
|
|
264
|
+
maxCacheItems: 1000,
|
|
265
|
+
maxCacheTTL: 3600000,
|
|
266
|
+
},
|
|
267
|
+
}),
|
|
268
|
+
}),
|
|
269
|
+
],
|
|
270
|
+
})
|
|
271
|
+
export class AppModule {}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## 📚 API Documentation
|
|
275
|
+
|
|
276
|
+
The module automatically generates REST API endpoints with customizable paths:
|
|
277
|
+
|
|
278
|
+
### Configuration Sections (default: `/config/section`)
|
|
279
|
+
|
|
280
|
+
- `GET /config/section` - List all sections
|
|
281
|
+
- `POST /config/section` - Create a new section
|
|
282
|
+
- `GET /config/section/:id` - Get section by ID
|
|
283
|
+
- `PUT /config/section/:id` - Update section
|
|
284
|
+
- `DELETE /config/section/:id` - Delete section
|
|
285
|
+
|
|
286
|
+
**Request Body for POST/PUT:**
|
|
287
|
+
```json
|
|
288
|
+
{
|
|
289
|
+
"name": "api-settings",
|
|
290
|
+
"description": "API configuration settings"
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Configuration Data (default: `/config/data`)
|
|
295
|
+
|
|
296
|
+
- `GET /config/data` - List all configuration data
|
|
297
|
+
- `POST /config/data` - Create new configuration
|
|
298
|
+
- `GET /config/data/:id` - Get configuration by ID
|
|
299
|
+
- `PUT /config/data/:id` - Update configuration
|
|
300
|
+
- `DELETE /config/data/:id` - Delete configuration
|
|
301
|
+
|
|
302
|
+
**Request Body for POST/PUT:**
|
|
303
|
+
```json
|
|
304
|
+
{
|
|
305
|
+
"name": "API_KEY",
|
|
306
|
+
"value": "your-secret-key",
|
|
307
|
+
"environment": "production",
|
|
308
|
+
"description": "Production API key",
|
|
309
|
+
"isEncrypted": true,
|
|
310
|
+
"section": { "id": "section-uuid-here" }
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Customizing API Endpoints
|
|
315
|
+
|
|
316
|
+
```typescript
|
|
317
|
+
CrudConfigModule.register({
|
|
318
|
+
controllersOptions: {
|
|
319
|
+
section: {
|
|
320
|
+
properties: {
|
|
321
|
+
path: 'api/v1/settings/sections',
|
|
322
|
+
name: 'CustomSectionController',
|
|
323
|
+
swagger: {
|
|
324
|
+
tags: ['Configuration Sections'],
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
data: {
|
|
329
|
+
properties: {
|
|
330
|
+
path: 'api/v1/settings/data',
|
|
331
|
+
routes: {
|
|
332
|
+
DELETE: { isEnabled: false }, // Disable deletion
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
})
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
## 🗄️ Database Schema
|
|
341
|
+
|
|
342
|
+
The module creates two main tables with the following default structure:
|
|
343
|
+
|
|
344
|
+
### Configuration Sections Table (`config_section`)
|
|
345
|
+
```sql
|
|
346
|
+
CREATE TABLE config_section (
|
|
347
|
+
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
348
|
+
name VARCHAR(128) NOT NULL UNIQUE,
|
|
349
|
+
description VARCHAR(512),
|
|
350
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
351
|
+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
352
|
+
);
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Configuration Data Table (`config_data`)
|
|
356
|
+
```sql
|
|
357
|
+
CREATE TABLE config_data (
|
|
358
|
+
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
359
|
+
name VARCHAR(128) NOT NULL,
|
|
360
|
+
value VARCHAR(8192) NOT NULL,
|
|
361
|
+
environment VARCHAR(64) NOT NULL,
|
|
362
|
+
description VARCHAR(512),
|
|
363
|
+
is_encrypted BOOLEAN DEFAULT FALSE,
|
|
364
|
+
section_id UUID NOT NULL REFERENCES config_section(id) ON DELETE CASCADE,
|
|
365
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
366
|
+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
367
|
+
UNIQUE(name, environment, section_id)
|
|
368
|
+
);
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
## 🔧 Advanced Configuration
|
|
372
|
+
|
|
373
|
+
### Encryption Support
|
|
374
|
+
|
|
375
|
+
The module provides built-in AES-256-GCM encryption for sensitive configuration values:
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
// Enable encryption globally
|
|
379
|
+
CrudConfigModule.register({
|
|
380
|
+
encryptionOptions: {
|
|
381
|
+
isEnabled: true,
|
|
382
|
+
encryptionKey: process.env.CONFIG_ENCRYPTION_KEY, // 32+ character key
|
|
383
|
+
},
|
|
384
|
+
})
|
|
385
|
+
|
|
386
|
+
// When encryption is enabled, all values are encrypted automatically
|
|
387
|
+
await configService.set({
|
|
388
|
+
section: 'database',
|
|
389
|
+
name: 'DB_PASSWORD',
|
|
390
|
+
value: 'my-secret-password',
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
// Retrieve and decrypt automatically
|
|
394
|
+
const config = await configService.get({
|
|
395
|
+
section: 'database',
|
|
396
|
+
name: 'DB_PASSWORD',
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
console.log(config.value); // Automatically decrypted value
|
|
400
|
+
console.log(config.isEncrypted); // true
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### Event-Driven Architecture
|
|
404
|
+
|
|
405
|
+
The module includes comprehensive event handling with both listeners and TypeORM subscribers:
|
|
406
|
+
|
|
407
|
+
```typescript
|
|
408
|
+
// Event listener example
|
|
409
|
+
@Injectable()
|
|
410
|
+
export class ConfigDataBeforeInsertListener {
|
|
411
|
+
@OnEvent('config-data.beforeInsert')
|
|
412
|
+
async handleBeforeInsert(payload: ConfigDataEventBeforeInsert) {
|
|
413
|
+
// Custom validation logic
|
|
414
|
+
const entity = payload.item;
|
|
415
|
+
const entityManager = payload.eventManager;
|
|
416
|
+
|
|
417
|
+
// Perform custom checks
|
|
418
|
+
return { isSuccess: true };
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// TypeORM subscriber for database-level events
|
|
423
|
+
@EventSubscriber()
|
|
424
|
+
export class ConfigDataBeforeInsertSubscriber {
|
|
425
|
+
beforeInsert(event: InsertEvent<IConfigData>) {
|
|
426
|
+
// Database-level validation
|
|
427
|
+
return Promise.resolve(true);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
### Headless Mode (Without Controllers)
|
|
433
|
+
|
|
434
|
+
```typescript
|
|
435
|
+
CrudConfigModule.register({
|
|
436
|
+
controllersOptions: {
|
|
437
|
+
section: { isEnabled: false },
|
|
438
|
+
data: { isEnabled: false },
|
|
439
|
+
},
|
|
440
|
+
})
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
This is perfect for:
|
|
444
|
+
- Background services that only need programmatic access
|
|
445
|
+
- Microservices that manage config through message queues
|
|
446
|
+
- Applications with custom GraphQL or gRPC interfaces
|
|
447
|
+
|
|
448
|
+
### Working with Multiple Environments
|
|
449
|
+
|
|
450
|
+
```typescript
|
|
451
|
+
// multi-env.service.ts
|
|
452
|
+
@Injectable()
|
|
453
|
+
export class MultiEnvironmentService {
|
|
454
|
+
constructor(
|
|
455
|
+
private readonly configService: CrudConfigService,
|
|
456
|
+
) {}
|
|
457
|
+
|
|
458
|
+
async setupEnvironmentConfigs() {
|
|
459
|
+
const environments = ['development', 'staging', 'production'];
|
|
460
|
+
|
|
461
|
+
for (const env of environments) {
|
|
462
|
+
await this.configService.set({
|
|
463
|
+
section: 'database',
|
|
464
|
+
name: 'DATABASE_URL',
|
|
465
|
+
environment: env,
|
|
466
|
+
value: `postgres://localhost:5432/${env}_db`,
|
|
467
|
+
description: `Database URL for ${env} environment`,
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
## 🛣 Roadmap
|
|
475
|
+
|
|
476
|
+
| Task / Feature | Status |
|
|
477
|
+
|---|---|
|
|
478
|
+
| Core dynamic entity system | ✅ Done |
|
|
479
|
+
| TypeORM integration with all databases | ✅ Done |
|
|
480
|
+
| Hierarchical configuration (sections/data) | ✅ Done |
|
|
481
|
+
| Full CRUD operations with REST API | ✅ Done |
|
|
482
|
+
| Swagger/OpenAPI documentation | ✅ Done |
|
|
483
|
+
| Multi-environment support | ✅ Done |
|
|
484
|
+
| Event-driven architecture with hooks | ✅ Done |
|
|
485
|
+
| Caching system with TTL | ✅ Done |
|
|
486
|
+
| Custom table names and prefixes | ✅ Done |
|
|
487
|
+
| Validation and constraints | ✅ Done |
|
|
488
|
+
| NestJS CRUD Automator integration | ✅ Done |
|
|
489
|
+
| TypeScript interfaces and types | ✅ Done |
|
|
490
|
+
| AES-256-GCM encryption support | ✅ Done |
|
|
491
|
+
| Async module registration | ✅ Done |
|
|
492
|
+
| Auto-section creation | ✅ Done |
|
|
493
|
+
| GraphQL API endpoints | 🚧 In Progress |
|
|
494
|
+
| Configuration versioning and history | 🚧 In Progress |
|
|
495
|
+
| Role-based access control (RBAC) | 🚧 In Progress |
|
|
496
|
+
| Configuration templates and inheritance | 🚧 In Progress |
|
|
497
|
+
| Real-time configuration updates via WebSocket | 🚧 In Progress |
|
|
498
|
+
| Configuration validation schemas | 🚧 In Progress |
|
|
499
|
+
| Bulk import/export functionality | 🚧 In Progress |
|
|
500
|
+
| Configuration diff and merge tools | 🚧 In Progress |
|
|
501
|
+
| Audit logging and change tracking | 🚧 In Progress |
|
|
502
|
+
| Configuration backup and restore | 🚧 In Progress |
|
|
503
|
+
| Integration with external secret managers | 🚧 In Progress |
|
|
504
|
+
|
|
505
|
+
## ❓ FAQ
|
|
506
|
+
|
|
507
|
+
### What databases are supported?
|
|
508
|
+
|
|
509
|
+
The module supports any database that TypeORM supports, including:
|
|
510
|
+
- **PostgreSQL** - Recommended for production
|
|
511
|
+
- **MySQL/MariaDB** - Popular choice for web applications
|
|
512
|
+
- **SQLite** - Perfect for development and testing
|
|
513
|
+
- **Microsoft SQL Server** - Enterprise database support
|
|
514
|
+
- **Oracle** - Enterprise-grade database
|
|
515
|
+
- **MongoDB** - NoSQL document database
|
|
516
|
+
- **CockroachDB** - Distributed SQL database
|
|
517
|
+
|
|
518
|
+
### How does this compare to environment variables?
|
|
519
|
+
|
|
520
|
+
While environment variables are great for simple configurations, this module provides:
|
|
521
|
+
- **Database persistence** - Configurations survive container restarts
|
|
522
|
+
- **Runtime updates** - Change configurations without redeployment
|
|
523
|
+
- **Hierarchical organization** - Group related configurations
|
|
524
|
+
- **Multi-environment support** - Manage dev/staging/prod from one place
|
|
525
|
+
- **Encryption support** - Secure sensitive data
|
|
526
|
+
- **REST API** - Manage configurations programmatically
|
|
527
|
+
- **Audit trails** - Track configuration changes
|
|
528
|
+
|
|
529
|
+
### Can I migrate from environment variables?
|
|
530
|
+
|
|
531
|
+
Yes! You can easily migrate by programmatically setting configurations during application startup:
|
|
532
|
+
|
|
533
|
+
```typescript
|
|
534
|
+
async function migrateFromEnvVars() {
|
|
535
|
+
const configs = [
|
|
536
|
+
{ section: 'database', name: 'DATABASE_URL', value: process.env.DATABASE_URL },
|
|
537
|
+
{ section: 'api', name: 'API_KEY', value: process.env.API_KEY },
|
|
538
|
+
// ... more configurations
|
|
539
|
+
];
|
|
540
|
+
|
|
541
|
+
for (const config of configs) {
|
|
542
|
+
await configService.set(config);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
### How do I handle sensitive configuration data?
|
|
548
|
+
|
|
549
|
+
The module provides built-in AES-256-GCM encryption support:
|
|
550
|
+
|
|
551
|
+
```typescript
|
|
552
|
+
CrudConfigModule.register({
|
|
553
|
+
encryptionOptions: {
|
|
554
|
+
isEnabled: true,
|
|
555
|
+
encryptionKey: process.env.CONFIG_ENCRYPTION_KEY,
|
|
556
|
+
},
|
|
557
|
+
})
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
Sensitive values are automatically encrypted before storage and decrypted when retrieved.
|
|
561
|
+
|
|
562
|
+
### Can I use this with microservices?
|
|
563
|
+
|
|
564
|
+
Absolutely! The module is perfect for microservice architectures:
|
|
565
|
+
- **Centralized configuration** - All services can share the same config database
|
|
566
|
+
- **Service-specific sections** - Organize configurations by service
|
|
567
|
+
- **Environment isolation** - Separate dev/staging/prod configurations
|
|
568
|
+
- **Dynamic updates** - Update configurations without service restarts
|
|
569
|
+
|
|
570
|
+
### How do I customize table names and field sizes?
|
|
571
|
+
|
|
572
|
+
The module provides extensive customization options:
|
|
573
|
+
|
|
574
|
+
```typescript
|
|
575
|
+
CrudConfigModule.register({
|
|
576
|
+
entityOptions: {
|
|
577
|
+
tablePrefix: 'myapp_',
|
|
578
|
+
configSection: {
|
|
579
|
+
tableName: 'configuration_sections',
|
|
580
|
+
maxNameLength: 256,
|
|
581
|
+
maxDescriptionLength: 1024,
|
|
582
|
+
},
|
|
583
|
+
configData: {
|
|
584
|
+
tableName: 'configuration_values',
|
|
585
|
+
maxValueLength: 16384, // 16KB values
|
|
586
|
+
maxEnvironmentLength: 128,
|
|
587
|
+
maxNameLength: 256,
|
|
588
|
+
maxDescriptionLength: 1024,
|
|
589
|
+
},
|
|
590
|
+
},
|
|
591
|
+
})
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
### What happens if the database is unavailable?
|
|
595
|
+
|
|
596
|
+
The module includes caching to handle temporary database outages:
|
|
597
|
+
- **In-memory cache** - Recently accessed configurations are cached
|
|
598
|
+
- **Configurable TTL** - Control how long configurations are cached
|
|
599
|
+
- **Graceful degradation** - Falls back to cached values when database is unavailable
|
|
600
|
+
|
|
601
|
+
### Can I use this without REST API endpoints?
|
|
602
|
+
|
|
603
|
+
Yes! The module supports "headless mode" where controllers are disabled:
|
|
604
|
+
|
|
605
|
+
```typescript
|
|
606
|
+
CrudConfigModule.register({
|
|
607
|
+
controllersOptions: {
|
|
608
|
+
section: { isEnabled: false },
|
|
609
|
+
data: { isEnabled: false },
|
|
610
|
+
},
|
|
611
|
+
})
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
### Is this production-ready?
|
|
615
|
+
|
|
616
|
+
Yes! The module is built with production use in mind:
|
|
617
|
+
- **Type-safe** - Full TypeScript support prevents runtime errors
|
|
618
|
+
- **Battle-tested** - Built on proven technologies (NestJS, TypeORM)
|
|
619
|
+
- **Scalable** - Works with enterprise databases
|
|
620
|
+
- **Secure** - Built-in encryption and validation
|
|
621
|
+
- **Observable** - Comprehensive logging and monitoring hooks
|
|
622
|
+
|
|
623
|
+
## 🔒 License
|
|
624
|
+
|
|
625
|
+
This project is licensed under **MIT License**
|
|
626
|
+
|
|
627
|
+
Copyright (c) 2025 ElsiKora
|
|
628
|
+
|
|
629
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
630
|
+
|
|
631
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
632
|
+
|
|
633
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/******************************************************************************
|
|
4
|
+
Copyright (c) Microsoft Corporation.
|
|
5
|
+
|
|
6
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
7
|
+
purpose with or without fee is hereby granted.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
***************************************************************************** */
|
|
17
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
function __decorate(decorators, target, key, desc) {
|
|
21
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
22
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
23
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
24
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function __param(paramIndex, decorator) {
|
|
28
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function __metadata(metadataKey, metadataValue) {
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
36
|
+
var e = new Error(message);
|
|
37
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
exports.__decorate = __decorate;
|
|
41
|
+
exports.__metadata = __metadata;
|
|
42
|
+
exports.__param = __param;
|
|
43
|
+
//# sourceMappingURL=tslib.es6.js.map
|