@cyberskill/shared 1.216.0 → 2.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/README.md +330 -222
- package/dist/config/config.util.d.ts +17 -0
- package/dist/config/env/env.util.d.ts +26 -0
- package/dist/config/eslint/index.d.ts +4 -0
- package/dist/config/graphql-codegen/graphql-codegen.util.cjs +1 -1
- package/dist/config/graphql-codegen/graphql-codegen.util.d.ts +23 -0
- package/dist/config/graphql-codegen/graphql-codegen.util.js +2 -1
- package/dist/config/vitest/vitest.e2e.cjs +1 -1
- package/dist/config/vitest/vitest.e2e.d.ts +16 -0
- package/dist/config/vitest/vitest.e2e.js +1 -1
- package/dist/config/vitest/vitest.unit.cjs +1 -1
- package/dist/config/vitest/vitest.unit.d.ts +18 -0
- package/dist/config/vitest/vitest.unit.js +1 -1
- package/dist/constant/common.d.ts +4 -0
- package/dist/constant/index.d.ts +3 -0
- package/dist/node/apollo-server/apollo-server.util.d.ts +15 -1
- package/dist/node/apollo-server/index.cjs +1 -1
- package/dist/node/apollo-server/index.js +1 -1
- package/dist/node/command/command.type.d.ts +26 -6
- package/dist/node/command/command.util.d.ts +50 -0
- package/dist/node/express/express.util.cjs +1 -1
- package/dist/node/express/express.util.d.ts +47 -0
- package/dist/node/express/express.util.js +9 -9
- package/dist/node/fs/fs.type.d.ts +6 -0
- package/dist/node/fs/fs.util.d.ts +48 -1
- package/dist/node/log/log.type.d.ts +6 -1
- package/dist/node/log/log.util.cjs +1 -1
- package/dist/node/log/log.util.d.ts +30 -2
- package/dist/node/log/log.util.js +33 -20
- package/dist/node/mongo/mongo.constant.d.ts +5 -0
- package/dist/node/mongo/mongo.type.d.ts +4 -4
- package/dist/node/mongo/mongo.util.cjs +5 -5
- package/dist/node/mongo/mongo.util.d.ts +337 -3
- package/dist/node/mongo/mongo.util.js +406 -79
- package/dist/node/package/package.type.d.ts +2 -2
- package/dist/node/package/package.util.cjs +1 -1
- package/dist/node/package/package.util.d.ts +52 -1
- package/dist/node/package/package.util.js +97 -92
- package/dist/node/path/path.constant.d.ts +9 -0
- package/dist/node/path/path.util.d.ts +24 -0
- package/dist/node/storage/storage.util.d.ts +44 -0
- package/dist/node/storage/storage.util.js +39 -0
- package/dist/node/upload/upload.util.d.ts +21 -0
- package/dist/node/ws/ts.util.d.ts +16 -0
- package/dist/react/apollo-client/apollo-client.component.d.ts +19 -1
- package/dist/react/apollo-client/apollo-client.component.js +1 -4
- package/dist/react/apollo-client/apollo-client.constant.d.ts +5 -0
- package/dist/react/apollo-client/apollo-client.context.d.ts +15 -0
- package/dist/react/apollo-client/apollo-client.hook.d.ts +12 -0
- package/dist/react/apollo-client/apollo-client.util.d.ts +48 -0
- package/dist/react/apollo-client/apollo-client.util.js +9 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.d.ts +19 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js +1 -4
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.d.ts +10 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.d.ts +10 -0
- package/dist/react/apollo-error/apollo-error.component.cjs +1 -1
- package/dist/react/apollo-error/apollo-error.component.d.ts +17 -0
- package/dist/react/apollo-error/apollo-error.component.js +10 -10
- package/dist/react/apollo-error/apollo-error.hook.d.ts +12 -0
- package/dist/react/apollo-error/apollo-error.provider.d.ts +15 -0
- package/dist/react/apollo-error/apollo-error.util.d.ts +17 -0
- package/dist/react/i18next/i18next.hook.d.ts +9 -0
- package/dist/react/i18next/i18next.util.d.ts +10 -0
- package/dist/react/loading/loading.component.d.ts +21 -0
- package/dist/react/loading/loading.hook.d.ts +12 -0
- package/dist/react/loading/loading.provider.d.ts +15 -0
- package/dist/react/log/log.util.d.ts +17 -0
- package/dist/react/next-intl/next-intl.constant.d.ts +9 -0
- package/dist/react/next-intl/next-intl.hoc.d.ts +16 -0
- package/dist/react/next-intl/next-intl.hook.d.ts +21 -0
- package/dist/react/next-intl/next-intl.provider.d.ts +21 -0
- package/dist/react/storage/storage.hook.d.ts +19 -0
- package/dist/react/storage/storage.hook.js +28 -30
- package/dist/react/storage/storage.util.d.ts +39 -0
- package/dist/react/storage/storage.util.js +33 -0
- package/dist/react/userback/userback.component.d.ts +18 -0
- package/dist/typescript/common.type.d.ts +6 -0
- package/dist/typescript/index.d.ts +3 -0
- package/dist/util/common/common.util.d.ts +19 -7
- package/dist/util/common/index.d.ts +3 -0
- package/dist/util/index.d.ts +3 -0
- package/dist/util/object/object.util.d.ts +25 -12
- package/dist/util/serializer/serializer.type.d.ts +1 -1
- package/dist/util/serializer/serializer.util.d.ts +8 -0
- package/dist/util/serializer/serializer.util.js +4 -4
- package/dist/util/string/string.util.cjs +1 -1
- package/dist/util/string/string.util.d.ts +30 -17
- package/dist/util/string/string.util.js +14 -16
- package/dist/util/validate/validate.util.d.ts +9 -3
- package/dist/util/validate/validate.util.js +5 -3
- package/package.json +21 -18
- /package/dist/node_modules/.pnpm/{vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.13_@vitest_browser@3.2.4_jiti@2.4.2_j_cac3da623d5688a51c0b1a2270e144db → vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.15_@vitest_browser@3.2.4_jiti@2.4.2_j_e4a333d8aa4b05d17db10875e249d94f}/node_modules/vitest/dist/config.cjs +0 -0
- /package/dist/node_modules/.pnpm/{vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.13_@vitest_browser@3.2.4_jiti@2.4.2_j_cac3da623d5688a51c0b1a2270e144db → vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.15_@vitest_browser@3.2.4_jiti@2.4.2_j_e4a333d8aa4b05d17db10875e249d94f}/node_modules/vitest/dist/config.js +0 -0
package/README.md
CHANGED
|
@@ -3,13 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
# CyberSkill Shared
|
|
5
5
|
|
|
6
|
-
**
|
|
6
|
+
**Enterprise-grade utility library for consistent, scalable development across CyberSkill projects**
|
|
7
7
|
|
|
8
|
-
[](https://npmjs.com/package/@cyberskill/shared)
|
|
9
|
-
[](https://npmjs.com/package/@cyberskill/shared)
|
|
10
|
-
[](https://nodejs.org/)
|
|
8
|
+
[](https://npmjs.com/package/@cyberskill/shared)
|
|
9
|
+
[](https://npmjs.com/package/@cyberskill/shared)
|
|
10
|
+
[](https://www.jsdocs.io/package/@cyberskill/shared)
|
|
11
|
+
[](https://opensource.org/licenses/MIT)
|
|
13
12
|
|
|
14
13
|
</div>
|
|
15
14
|
|
|
@@ -17,70 +16,162 @@
|
|
|
17
16
|
|
|
18
17
|
## 📋 Table of Contents
|
|
19
18
|
|
|
20
|
-
- [Overview](
|
|
21
|
-
- [Features](
|
|
22
|
-
- [
|
|
23
|
-
- [
|
|
24
|
-
- [
|
|
25
|
-
- [API Reference](
|
|
26
|
-
- [Development](
|
|
27
|
-
- [Contributing](
|
|
28
|
-
- [
|
|
19
|
+
- [Overview](#-overview)
|
|
20
|
+
- [Key Features](#-key-features)
|
|
21
|
+
- [Architecture](#️-architecture)
|
|
22
|
+
- [Installation](#-installation)
|
|
23
|
+
- [Quick Start](#-quick-start)
|
|
24
|
+
- [API Reference](#-api-reference)
|
|
25
|
+
- [Development](#️-development)
|
|
26
|
+
- [Contributing](#-contributing)
|
|
27
|
+
- [Support](#-support)
|
|
28
|
+
- [License](#-license)
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
32
|
-
##
|
|
32
|
+
## 🎯 Overview
|
|
33
33
|
|
|
34
|
-
CyberSkill Shared is a
|
|
34
|
+
CyberSkill Shared is a comprehensive, enterprise-grade utility library designed to standardize development practices across CyberSkill projects. Built with TypeScript-first architecture, it provides a robust foundation of utilities, configurations, and components that ensure consistency, maintainability, and developer productivity at scale.
|
|
35
35
|
|
|
36
|
-
###
|
|
36
|
+
### 🏆 Why Choose CyberSkill Shared?
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
| Feature | Benefit |
|
|
39
|
+
| ---------------------- | ------------------------------------------------------- |
|
|
40
|
+
| **🔄 Consistency** | Standardized patterns and utilities across all projects |
|
|
41
|
+
| **⚡ Productivity** | Pre-built solutions for common development tasks |
|
|
42
|
+
| **🛡️ Reliability** | Type-safe implementations with comprehensive testing |
|
|
43
|
+
| **📈 Scalability** | Modular architecture that grows with your needs |
|
|
44
|
+
| **🔧 Maintainability** | Well-documented, clean, and extensible codebase |
|
|
45
|
+
| **🚀 Performance** | Optimized for production with minimal bundle impact |
|
|
46
|
+
| **🔒 Security** | Built-in security best practices and validation |
|
|
47
|
+
|
|
48
|
+
### 🎯 Target Use Cases
|
|
49
|
+
|
|
50
|
+
- **Enterprise Applications**: Large-scale applications requiring consistency and maintainability
|
|
51
|
+
- **Microservices**: Distributed systems needing shared utilities and configurations
|
|
52
|
+
- **Full-Stack Development**: Projects spanning frontend and backend with shared logic
|
|
53
|
+
- **Team Collaboration**: Development teams requiring standardized tooling and patterns
|
|
54
|
+
- **Rapid Prototyping**: Quick development with pre-built, tested components
|
|
43
55
|
|
|
44
56
|
---
|
|
45
57
|
|
|
46
|
-
## ✨ Features
|
|
58
|
+
## ✨ Key Features
|
|
47
59
|
|
|
48
|
-
### 🛠️ Core Utilities
|
|
60
|
+
### 🛠️ Core Utilities & Helpers
|
|
61
|
+
|
|
62
|
+
<details>
|
|
63
|
+
<summary><strong>🔧 Utility Functions</strong></summary>
|
|
49
64
|
|
|
50
65
|
- **Type-safe utilities** for common operations
|
|
51
66
|
- **Object manipulation** and validation helpers
|
|
52
67
|
- **String processing** and formatting functions
|
|
53
68
|
- **Serialization** and data transformation tools
|
|
69
|
+
- **Validation** frameworks with comprehensive error handling
|
|
70
|
+
|
|
71
|
+
</details>
|
|
54
72
|
|
|
55
|
-
|
|
73
|
+
<details>
|
|
74
|
+
<summary><strong>⚙️ Configuration Management</strong></summary>
|
|
56
75
|
|
|
57
|
-
- **Environment configuration** with type safety
|
|
58
|
-
- **ESLint configurations** for consistent code quality
|
|
59
|
-
- **Testing setups** for unit and
|
|
60
|
-
- **Build tool configurations** optimized for performance
|
|
76
|
+
- **Environment configuration** with type safety and validation
|
|
77
|
+
- **ESLint configurations** for consistent code quality across projects
|
|
78
|
+
- **Testing setups** for unit, integration, and e2e tests
|
|
79
|
+
- **Build tool configurations** optimized for performance and DX
|
|
80
|
+
- **Git hooks** and commit message validation
|
|
61
81
|
|
|
62
|
-
|
|
82
|
+
</details>
|
|
63
83
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
- **WebSocket management** tools
|
|
67
|
-
- **File system operations** with enhanced error handling
|
|
68
|
-
- **CLI development** utilities
|
|
84
|
+
<details>
|
|
85
|
+
<summary><strong>🌐 Node.js Integration</strong></summary>
|
|
69
86
|
|
|
70
|
-
|
|
87
|
+
- **Express.js utilities** for API development with middleware support
|
|
88
|
+
- **MongoDB integration** with advanced query builders and validation
|
|
89
|
+
- **WebSocket management** tools for real-time applications
|
|
90
|
+
- **File system operations** with enhanced error handling and validation
|
|
91
|
+
- **CLI development** utilities for command-line applications
|
|
92
|
+
- **Package management** with dependency resolution and updates
|
|
71
93
|
|
|
72
|
-
|
|
73
|
-
|
|
94
|
+
</details>
|
|
95
|
+
|
|
96
|
+
<details>
|
|
97
|
+
<summary><strong>⚛️ React Ecosystem</strong></summary>
|
|
98
|
+
|
|
99
|
+
- **Apollo Client** integration with error handling and caching
|
|
100
|
+
- **Internationalization** (i18n) support for multi-language applications
|
|
74
101
|
- **Loading states** and user feedback components
|
|
75
|
-
- **Storage management** hooks and utilities
|
|
76
|
-
- **Toast notifications** system
|
|
102
|
+
- **Storage management** hooks and utilities for client-side persistence
|
|
103
|
+
- **Toast notifications** system with customizable themes
|
|
104
|
+
- **User feedback** integration for product improvement
|
|
105
|
+
|
|
106
|
+
</details>
|
|
107
|
+
|
|
108
|
+
<details>
|
|
109
|
+
<summary><strong>📝 TypeScript Excellence</strong></summary>
|
|
77
110
|
|
|
78
|
-
|
|
111
|
+
- **Comprehensive type definitions** for all utilities and components
|
|
112
|
+
- **React component types** with proper prop validation
|
|
113
|
+
- **Utility type helpers** for advanced TypeScript patterns
|
|
114
|
+
- **Style declaration files** for CSS-in-JS solutions
|
|
115
|
+
- **Generic type support** for flexible, reusable components
|
|
79
116
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
117
|
+
</details>
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 🏗️ Architecture
|
|
122
|
+
|
|
123
|
+
### 📁 Project Structure
|
|
124
|
+
|
|
125
|
+
```text
|
|
126
|
+
shared/
|
|
127
|
+
├── 📁 public/ # Static assets and configuration
|
|
128
|
+
│ ├── favicon/ # Application icons and manifest
|
|
129
|
+
│ └── tsconfig.base.json # Base TypeScript configuration
|
|
130
|
+
├── 📁 src/
|
|
131
|
+
│ ├── 📁 config/ # Application configuration
|
|
132
|
+
│ │ ├── commitlint/ # Git commit message validation
|
|
133
|
+
│ │ ├── eslint/ # Code quality and style rules
|
|
134
|
+
│ │ ├── env/ # Environment variable management
|
|
135
|
+
│ │ ├── graphql-codegen/ # GraphQL code generation setup
|
|
136
|
+
│ │ ├── lint-staged/ # Pre-commit code quality checks
|
|
137
|
+
│ │ └── vitest/ # Testing framework configuration
|
|
138
|
+
│ ├── 📁 constant/ # Shared constants and enums
|
|
139
|
+
│ ├── 📁 node/ # Node.js utilities and modules
|
|
140
|
+
│ │ ├── apollo-server/ # Apollo Server integration helpers
|
|
141
|
+
│ │ ├── cli/ # Command-line interface utilities
|
|
142
|
+
│ │ ├── command/ # Command execution and management
|
|
143
|
+
│ │ ├── express/ # Express.js framework utilities
|
|
144
|
+
│ │ ├── fs/ # File system operations
|
|
145
|
+
│ │ ├── log/ # Structured logging and error handling
|
|
146
|
+
│ │ ├── mongo/ # MongoDB ODM and query builders
|
|
147
|
+
│ │ ├── package/ # Package management and dependency resolution
|
|
148
|
+
│ │ ├── path/ # Path manipulation and resolution
|
|
149
|
+
│ │ ├── storage/ # Data persistence and caching
|
|
150
|
+
│ │ ├── upload/ # File upload handling and validation
|
|
151
|
+
│ │ └── ws/ # WebSocket connection management
|
|
152
|
+
│ ├── 📁 react/ # React utilities and components
|
|
153
|
+
│ │ ├── apollo-client/ # Apollo Client setup and configuration
|
|
154
|
+
│ │ ├── apollo-error/ # GraphQL error handling and display
|
|
155
|
+
│ │ ├── i18next/ # Internationalization framework
|
|
156
|
+
│ │ ├── loading/ # Loading state management and UI
|
|
157
|
+
│ │ ├── log/ # Client-side logging utilities
|
|
158
|
+
│ │ ├── next-intl/ # Next.js internationalization
|
|
159
|
+
│ │ ├── storage/ # Browser storage management
|
|
160
|
+
│ │ ├── toast/ # Toast notification system
|
|
161
|
+
│ │ └── userback/ # User feedback and analytics
|
|
162
|
+
│ ├── 📁 typescript/ # TypeScript type definitions
|
|
163
|
+
│ └── 📁 util/ # Utility functions and helpers
|
|
164
|
+
│ ├── common/ # Common utility types and functions
|
|
165
|
+
│ ├── object/ # Object manipulation and transformation
|
|
166
|
+
│ ├── serializer/ # Data serialization and deserialization
|
|
167
|
+
│ ├── string/ # String processing and formatting
|
|
168
|
+
│ └── validate/ # Data validation and sanitization
|
|
169
|
+
├── 📄 package.json # Project manifest and dependencies
|
|
170
|
+
├── 📄 tsconfig.json # TypeScript compiler configuration
|
|
171
|
+
├── 📄 eslint.config.js # ESLint configuration
|
|
172
|
+
├── 📄 vite.config.ts # Vite build tool configuration
|
|
173
|
+
└── 📄 README.md # Project documentation
|
|
174
|
+
```
|
|
84
175
|
|
|
85
176
|
---
|
|
86
177
|
|
|
@@ -88,10 +179,11 @@ CyberSkill Shared is a modular, TypeScript-first utility library designed to sta
|
|
|
88
179
|
|
|
89
180
|
### Prerequisites
|
|
90
181
|
|
|
91
|
-
- Node.js 18
|
|
92
|
-
- pnpm 8
|
|
182
|
+
- **Node.js**: 18.0.0 or higher
|
|
183
|
+
- **pnpm**: 8.0.0 or higher (recommended)
|
|
184
|
+
- **TypeScript**: 5.0.0 or higher
|
|
93
185
|
|
|
94
|
-
###
|
|
186
|
+
### Package Installation
|
|
95
187
|
|
|
96
188
|
```bash
|
|
97
189
|
# Using pnpm (recommended)
|
|
@@ -104,6 +196,21 @@ npm install @cyberskill/shared
|
|
|
104
196
|
yarn add @cyberskill/shared
|
|
105
197
|
```
|
|
106
198
|
|
|
199
|
+
### TypeScript Configuration
|
|
200
|
+
|
|
201
|
+
Add to your `tsconfig.json`:
|
|
202
|
+
|
|
203
|
+
```json
|
|
204
|
+
{
|
|
205
|
+
"compilerOptions": {
|
|
206
|
+
"baseUrl": ".",
|
|
207
|
+
"paths": {
|
|
208
|
+
"@cyberskill/shared/*": ["node_modules/@cyberskill/shared/src/*"]
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
107
214
|
---
|
|
108
215
|
|
|
109
216
|
## 🏃 Quick Start
|
|
@@ -111,116 +218,144 @@ yarn add @cyberskill/shared
|
|
|
111
218
|
### Basic Usage
|
|
112
219
|
|
|
113
220
|
```typescript
|
|
114
|
-
import {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
221
|
+
import {
|
|
222
|
+
catchError,
|
|
223
|
+
formatCurrency,
|
|
224
|
+
isEmpty,
|
|
225
|
+
validateEmail
|
|
226
|
+
} from '@cyberskill/shared';
|
|
227
|
+
|
|
228
|
+
// Email validation
|
|
229
|
+
const isValidEmail = validateEmail('user@example.com');
|
|
230
|
+
console.log(isValidEmail); // true
|
|
231
|
+
|
|
232
|
+
// Currency formatting
|
|
233
|
+
const formattedPrice = formatCurrency(1234.56, 'USD');
|
|
234
|
+
console.log(formattedPrice); // "$1,234.56"
|
|
235
|
+
|
|
236
|
+
// Empty value checking
|
|
237
|
+
const isEmptyValue = isEmpty(null); // true
|
|
238
|
+
const hasValue = isEmpty('hello'); // false
|
|
239
|
+
|
|
240
|
+
// Error handling
|
|
241
|
+
try {
|
|
242
|
+
// Your code here
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
const handledError = catchError(error);
|
|
246
|
+
console.log(handledError.message);
|
|
247
|
+
}
|
|
121
248
|
```
|
|
122
249
|
|
|
123
|
-
### React
|
|
250
|
+
### React Integration
|
|
124
251
|
|
|
125
252
|
```tsx
|
|
126
|
-
import {
|
|
127
|
-
|
|
253
|
+
import {
|
|
254
|
+
ApolloProvider,
|
|
255
|
+
LoadingProvider,
|
|
256
|
+
useApolloError,
|
|
257
|
+
useLoading
|
|
258
|
+
} from '@cyberskill/shared';
|
|
259
|
+
import React from 'react';
|
|
260
|
+
|
|
261
|
+
// Main application wrapper
|
|
262
|
+
/**
|
|
263
|
+
*
|
|
264
|
+
*/
|
|
128
265
|
// eslint-disable-next-line react-refresh/only-export-components
|
|
129
266
|
function App() {
|
|
130
267
|
return (
|
|
131
|
-
<
|
|
132
|
-
<
|
|
133
|
-
|
|
268
|
+
<ApolloProvider options={{ uri: 'https://api.example.com/graphql' }}>
|
|
269
|
+
<LoadingProvider>
|
|
270
|
+
<MyApplication />
|
|
271
|
+
</LoadingProvider>
|
|
272
|
+
</ApolloProvider>
|
|
134
273
|
);
|
|
135
274
|
}
|
|
136
275
|
|
|
276
|
+
// Component with loading and error handling
|
|
277
|
+
/**
|
|
278
|
+
*
|
|
279
|
+
*/
|
|
137
280
|
// eslint-disable-next-line react-refresh/only-export-components
|
|
138
281
|
function MyComponent() {
|
|
139
282
|
const { showLoading, hideLoading } = useLoading();
|
|
283
|
+
const { showError } = useApolloError();
|
|
284
|
+
|
|
285
|
+
const handleAsyncOperation = async () => {
|
|
286
|
+
try {
|
|
287
|
+
showLoading();
|
|
288
|
+
// Your async operation
|
|
289
|
+
await someAsyncTask();
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
showError(error);
|
|
293
|
+
}
|
|
294
|
+
finally {
|
|
295
|
+
hideLoading();
|
|
296
|
+
}
|
|
297
|
+
};
|
|
140
298
|
|
|
141
|
-
|
|
142
|
-
|
|
299
|
+
return (
|
|
300
|
+
<div>
|
|
301
|
+
<button type="button" onClick={handleAsyncOperation}>
|
|
302
|
+
Perform Operation
|
|
303
|
+
</button>
|
|
304
|
+
</div>
|
|
305
|
+
);
|
|
143
306
|
}
|
|
144
307
|
```
|
|
145
308
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
## 📚 Documentation
|
|
149
|
-
|
|
150
|
-
For detailed documentation, visit our [documentation site](https://docs.cyberskill.com/shared) or check the [JSDocs reference](https://www.jsdocs.io/package/@cyberskill/shared).
|
|
151
|
-
|
|
152
|
-
### Key Documentation Sections
|
|
153
|
-
|
|
154
|
-
- [Getting Started Guide](https://docs.cyberskill.com/shared/getting-started)
|
|
155
|
-
- [API Reference](https://docs.cyberskill.com/shared/api)
|
|
156
|
-
- [Migration Guide](https://docs.cyberskill.com/shared/migration)
|
|
157
|
-
- [Best Practices](https://docs.cyberskill.com/shared/best-practices)
|
|
309
|
+
### Node.js Integration
|
|
158
310
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
| **userback** | User feedback integration | `@cyberskill/shared/react/userback` |
|
|
202
|
-
|
|
203
|
-
### Util Modules
|
|
204
|
-
|
|
205
|
-
| Module | Description | Import Path |
|
|
206
|
-
| -------------- | -------------------------------- | ------------------------------------ |
|
|
207
|
-
| **common** | Common utility types and helpers | `@cyberskill/shared/util/common` |
|
|
208
|
-
| **object** | Object manipulation utilities | `@cyberskill/shared/util/object` |
|
|
209
|
-
| **serializer** | Serialization and transformation | `@cyberskill/shared/util/serializer` |
|
|
210
|
-
| **string** | String processing utilities | `@cyberskill/shared/util/string` |
|
|
211
|
-
| **validate** | Validation helpers | `@cyberskill/shared/util/validate` |
|
|
311
|
+
```typescript
|
|
312
|
+
import {
|
|
313
|
+
createCorsOptions,
|
|
314
|
+
mongo,
|
|
315
|
+
RESPONSE_STATUS,
|
|
316
|
+
throwError
|
|
317
|
+
} from '@cyberskill/shared';
|
|
318
|
+
// Express.js setup with CORS
|
|
319
|
+
import express from 'express';
|
|
320
|
+
|
|
321
|
+
const app = express();
|
|
322
|
+
|
|
323
|
+
const corsOptions = createCorsOptions({
|
|
324
|
+
isDev: process.env.NODE_ENV === 'development',
|
|
325
|
+
whiteList: ['https://example.com', 'https://api.example.com']
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
app.use(cors(corsOptions));
|
|
329
|
+
|
|
330
|
+
// MongoDB integration
|
|
331
|
+
const mongoose = await mongo.connect({
|
|
332
|
+
uri: process.env.MONGODB_URI,
|
|
333
|
+
options: {
|
|
334
|
+
maxPoolSize: 10,
|
|
335
|
+
serverSelectionTimeoutMS: 5000
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
// Error handling
|
|
340
|
+
app.use('/api/users', (req, res, next) => {
|
|
341
|
+
try {
|
|
342
|
+
// Your route logic
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
throwError({
|
|
346
|
+
message: 'User operation failed',
|
|
347
|
+
status: RESPONSE_STATUS.INTERNAL_SERVER_ERROR,
|
|
348
|
+
type: 'rest'
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
```
|
|
212
353
|
|
|
213
354
|
---
|
|
214
355
|
|
|
215
356
|
## 🛠️ Development
|
|
216
357
|
|
|
217
|
-
###
|
|
218
|
-
|
|
219
|
-
- Node.js 22+
|
|
220
|
-
- pnpm 10+
|
|
221
|
-
- Git
|
|
222
|
-
|
|
223
|
-
### Setup
|
|
358
|
+
### Quick Setup
|
|
224
359
|
|
|
225
360
|
```bash
|
|
226
361
|
# Clone the repository
|
|
@@ -232,105 +367,60 @@ pnpm install
|
|
|
232
367
|
|
|
233
368
|
# Build the project
|
|
234
369
|
pnpm run build
|
|
370
|
+
|
|
371
|
+
# Start development mode
|
|
372
|
+
pnpm run dev
|
|
235
373
|
```
|
|
236
374
|
|
|
237
375
|
### Available Scripts
|
|
238
376
|
|
|
239
|
-
| Command
|
|
240
|
-
|
|
|
241
|
-
| `pnpm run dev`
|
|
242
|
-
| `pnpm run build`
|
|
243
|
-
| `pnpm run lint`
|
|
244
|
-
| `pnpm run lint:fix`
|
|
245
|
-
| `pnpm run test
|
|
246
|
-
| `pnpm run
|
|
247
|
-
| `pnpm run
|
|
248
|
-
| `pnpm run
|
|
249
|
-
| `pnpm run ready` | Prepare project for development |
|
|
377
|
+
| Command | Description | Usage |
|
|
378
|
+
| ------------------- | -------------------------------------- | ------------ |
|
|
379
|
+
| `pnpm run dev` | Start development mode with hot reload | Development |
|
|
380
|
+
| `pnpm run build` | Build for production | Production |
|
|
381
|
+
| `pnpm run lint` | Check for linting issues | Code Quality |
|
|
382
|
+
| `pnpm run lint:fix` | Fix linting issues automatically | Code Quality |
|
|
383
|
+
| `pnpm run test` | Run tests | Testing |
|
|
384
|
+
| `pnpm run inspect` | Inspect project dependencies | Analysis |
|
|
385
|
+
| `pnpm run reset` | Reset project state | Maintenance |
|
|
386
|
+
| `pnpm run ready` | Prepare project for development | Setup |
|
|
250
387
|
|
|
251
|
-
|
|
388
|
+
For detailed development guidelines, code standards, and contribution workflow, see our [Contributing Guide](CONTRIBUTING.md).
|
|
252
389
|
|
|
253
|
-
|
|
254
|
-
shared/
|
|
255
|
-
├── public/ # Static assets (favicons, manifest, etc.)
|
|
256
|
-
├── src/
|
|
257
|
-
│ ├── config/ # App configuration (commitlint, eslint, env, graphql-codegen, lint-staged, vitest)
|
|
258
|
-
│ ├── constant/ # Static values and constants
|
|
259
|
-
│ ├── node/ # Node.js utilities and modules
|
|
260
|
-
│ │ ├── apollo-server/ # Apollo Server helpers
|
|
261
|
-
│ │ ├── cli/ # CLI utilities
|
|
262
|
-
│ │ ├── command/ # Command execution helpers
|
|
263
|
-
│ │ ├── express/ # Express.js utilities
|
|
264
|
-
│ │ ├── fs/ # File system helpers
|
|
265
|
-
│ │ ├── log/ # Logging utilities
|
|
266
|
-
│ │ ├── mongo/ # MongoDB helpers
|
|
267
|
-
│ │ ├── package/ # Package management
|
|
268
|
-
│ │ ├── path/ # Path utilities
|
|
269
|
-
│ │ ├── storage/ # Storage helpers
|
|
270
|
-
│ │ ├── upload/ # File upload utilities
|
|
271
|
-
│ │ └── ws/ # WebSocket utilities
|
|
272
|
-
│ ├── react/ # React utilities and modules
|
|
273
|
-
│ │ ├── apollo-client/ # Apollo Client integration
|
|
274
|
-
│ │ ├── apollo-error/ # Apollo error handling
|
|
275
|
-
│ │ ├── i18next/ # Internationalization (i18n)
|
|
276
|
-
│ │ ├── loading/ # Loading state management
|
|
277
|
-
│ │ ├── log/ # Logging utilities
|
|
278
|
-
│ │ ├── next-intl/ # Next.js internationalization
|
|
279
|
-
│ │ ├── storage/ # Client-side storage
|
|
280
|
-
│ │ ├── toast/ # Toast notifications
|
|
281
|
-
│ │ └── userback/ # User feedback integration
|
|
282
|
-
│ ├── typescript/ # TypeScript types and interfaces
|
|
283
|
-
│ └── util/ # Utility functions and helpers
|
|
284
|
-
│ ├── common/ # Common utilities
|
|
285
|
-
│ ├── object/ # Object manipulation
|
|
286
|
-
│ ├── serializer/ # Serialization helpers
|
|
287
|
-
│ ├── string/ # String utilities
|
|
288
|
-
│ └── validate/ # Validation helpers
|
|
289
|
-
├── package.json # Project manifest
|
|
290
|
-
├── tsconfig.json # TypeScript configuration
|
|
291
|
-
└── ... # Other configuration and metadata files
|
|
292
|
-
```
|
|
390
|
+
---
|
|
293
391
|
|
|
294
|
-
|
|
392
|
+
## 🤝 Contributing
|
|
295
393
|
|
|
296
|
-
|
|
297
|
-
# Run all tests
|
|
298
|
-
pnpm run test
|
|
394
|
+
We welcome contributions from the community! Please read our [Contributing Guide](CONTRIBUTING.md) for detailed information about our development process, code standards, and contribution workflow.
|
|
299
395
|
|
|
300
|
-
|
|
301
|
-
pnpm run test:unit
|
|
396
|
+
### Quick Start for Contributors
|
|
302
397
|
|
|
303
|
-
|
|
304
|
-
|
|
398
|
+
1. **Fork** the repository
|
|
399
|
+
2. **Create** a feature branch (`git checkout -b feature/amazing-feature`)
|
|
400
|
+
3. **Make** your changes following our standards
|
|
401
|
+
4. **Test** your changes thoroughly
|
|
402
|
+
5. **Commit** with conventional commit messages
|
|
403
|
+
6. **Push** to your branch and create a Pull Request
|
|
305
404
|
|
|
306
|
-
|
|
307
|
-
pnpm run test:coverage
|
|
308
|
-
```
|
|
405
|
+
For complete guidelines, see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
309
406
|
|
|
310
407
|
---
|
|
311
408
|
|
|
312
|
-
##
|
|
409
|
+
## 🆘 Support
|
|
410
|
+
|
|
411
|
+
### Getting Help
|
|
313
412
|
|
|
314
|
-
|
|
413
|
+
- **🐛 Issues**: [GitHub Issues](https://github.com/cyberskill-world/shared/issues)
|
|
414
|
+
- **💬 Discussions**: [GitHub Discussions](https://github.com/cyberskill-world/shared/discussions)
|
|
415
|
+
- **📧 Email**: [support@cyberskill.world](mailto:support@cyberskill.world)
|
|
315
416
|
|
|
316
|
-
###
|
|
417
|
+
### Community Resources
|
|
317
418
|
|
|
318
|
-
|
|
319
|
-
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
320
|
-
3. Make your changes
|
|
321
|
-
4. Add tests for new functionality
|
|
322
|
-
5. Ensure all tests pass (`pnpm run test`)
|
|
323
|
-
6. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
324
|
-
7. Push to the branch (`git push origin feature/amazing-feature`)
|
|
325
|
-
8. Open a Pull Request
|
|
419
|
+
- **📚 API Reference**: [JSDocs](https://www.jsdocs.io/package/@cyberskill/shared)
|
|
326
420
|
|
|
327
|
-
###
|
|
421
|
+
### Migration Support
|
|
328
422
|
|
|
329
|
-
-
|
|
330
|
-
- Write comprehensive tests
|
|
331
|
-
- Update documentation for new features
|
|
332
|
-
- Follow our ESLint configuration
|
|
333
|
-
- Use conventional commit messages
|
|
423
|
+
- **📋 Changelog**: [Release Notes](https://github.com/cyberskill-world/shared/releases)
|
|
334
424
|
|
|
335
425
|
---
|
|
336
426
|
|
|
@@ -338,15 +428,30 @@ We welcome contributions from the community! Please read our [Contributing Guide
|
|
|
338
428
|
|
|
339
429
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
340
430
|
|
|
431
|
+
**MIT License Benefits:**
|
|
432
|
+
|
|
433
|
+
- ✅ Commercial use allowed
|
|
434
|
+
- ✅ Modification permitted
|
|
435
|
+
- ✅ Distribution allowed
|
|
436
|
+
- ✅ Private use allowed
|
|
437
|
+
- ✅ No warranty provided
|
|
438
|
+
- ✅ No liability for damages
|
|
439
|
+
|
|
341
440
|
---
|
|
342
441
|
|
|
343
442
|
## 🏢 About CyberSkill
|
|
344
443
|
|
|
345
|
-
CyberSkill JSC is a technology company focused on building innovative solutions for the cybersecurity industry. Our shared libraries and tools help developers create secure, scalable, and maintainable applications.
|
|
444
|
+
CyberSkill JSC is a leading technology company focused on building innovative solutions for the cybersecurity industry. Our shared libraries and tools help developers create secure, scalable, and maintainable applications that meet enterprise-grade standards.
|
|
445
|
+
|
|
446
|
+
### Company Information
|
|
447
|
+
|
|
448
|
+
- **🌐 Website**: [https://cyberskill.world](https://cyberskill.world)
|
|
449
|
+
- **🐙 GitHub**: [https://github.com/cyberskill-world](https://github.com/cyberskill-world)
|
|
450
|
+
- **📧 Contact**: [hello@cyberskill.world](mailto:hello@cyberskill.world)
|
|
451
|
+
|
|
452
|
+
### Our Mission
|
|
346
453
|
|
|
347
|
-
|
|
348
|
-
- **GitHub**: [https://github.com/cyberskill-world](https://github.com/cyberskill-world)
|
|
349
|
-
- **Documentation**: [https://docs.cyberskill.com](https://docs.cyberskill.com)
|
|
454
|
+
To provide developers with the tools and utilities they need to build secure, scalable, and maintainable applications that protect users and organizations in an increasingly complex digital landscape.
|
|
350
455
|
|
|
351
456
|
---
|
|
352
457
|
|
|
@@ -354,9 +459,12 @@ CyberSkill JSC is a technology company focused on building innovative solutions
|
|
|
354
459
|
<p>Made with ❤️ by the <a href="https://github.com/cyberskill-world">CyberSkill Team</a></p>
|
|
355
460
|
|
|
356
461
|
<p>
|
|
357
|
-
<a href="https://cyberskill.
|
|
358
|
-
<a href="https://docs.cyberskill.com">Documentation</a> •
|
|
462
|
+
<a href="https://cyberskill.world">Website</a> •
|
|
359
463
|
<a href="https://github.com/cyberskill-world/shared/issues">Issues</a> •
|
|
360
464
|
<a href="https://github.com/cyberskill-world/shared/discussions">Discussions</a>
|
|
361
465
|
</p>
|
|
466
|
+
|
|
467
|
+
<p>
|
|
468
|
+
<sub>If this project helps you, please consider giving us a ⭐ on GitHub!</sub>
|
|
469
|
+
</p>
|
|
362
470
|
</div>
|