Skip to content

Commit bfce2a4

Browse files
feat: Refactor FastKit configuration management
- Removed the config.validation.ts file, consolidating configuration schemas and validation logic. - Enhanced env.manager.ts to build a demo .env file with comprehensive comments and example values. - Deleted index.ts as part of the restructuring of the configuration module. - Introduced FastKit.constant.ts and env.constant.ts for better organization of environment constants and types. - Updated env.constant.ts to utilize Zod for environment variable validation and parsing. - Created a new test.ts file to demonstrate the usage of FastKit with Express. - Modified tsconfig.json to include path aliases for easier imports.
1 parent 1667b85 commit bfce2a4

20 files changed

Lines changed: 439 additions & 1703 deletions

.env.fastkit

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# ===============================================================
2+
# FastKit Demo Environment File
3+
# This file was automatically generated by FastKit.
4+
#
5+
# ➤ GitHub: https://github.com/abhishek-nexgen-dev
6+
# ➤ Created on: 2025-06-28T14:42:28.168Z
7+
#
8+
# This file contains example environment variables for development.
9+
# Please modify these values as needed for your local setup.
10+
11+
# ----------------------------
12+
# Server Configuration
13+
# ----------------------------
14+
PORT=3000
15+
HOST=localhost
16+
NODE_ENV=development
17+
ENVIRONMENT=development
18+
19+
# ----------------------------
20+
# Database Configuration
21+
# ----------------------------
22+
DATABASE_TYPE=mongodb
23+
DATABASE_URL=mongodb://localhost:27017/fastkit
24+
DATABASE_HOST=localhost
25+
DATABASE_PORT=27017
26+
DATABASE_USERNAME=your-db-username
27+
DATABASE_PASSWORD=your-db-password
28+
DATABASE_NAME=fastkit
29+
30+
# ----------------------------
31+
# JWT Authentication
32+
# ----------------------------
33+
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
34+
JWT_EXPIRES_IN=24h
35+
JWT_ALGORITHM=HS256
36+
37+
# ----------------------------
38+
# CORS Settings
39+
# ----------------------------
40+
CORS_ORIGIN=true
41+
CORS_METHODS=GET,POST,PUT,DELETE,PATCH
42+
CORS_ALLOWED_HEADERS=Content-Type,Authorization
43+
CORS_CREDENTIALS=true
44+
45+
# ----------------------------
46+
# Security Settings
47+
# ----------------------------
48+
RATE_LIMIT_WINDOW_MS=900000
49+
RATE_LIMIT_MAX=100
50+
SECURITY_HELMET=true
51+
SECURITY_COMPRESSION=true
52+
SECURITY_MORGAN=true
53+
54+
# ----------------------------
55+
# Email Settings
56+
# ----------------------------
57+
EMAIL_SERVICE=gmail
58+
EMAIL_HOST=smtp.gmail.com
59+
EMAIL_PORT=587
60+
EMAIL_SECURE=false
61+
EMAIL_USERNAME=your-email@gmail.com
62+
EMAIL_PASSWORD=your-app-password
63+
EMAIL_FROM=noreply@yourapp.com
64+
65+
# ----------------------------
66+
# Custom Variables
67+
# ----------------------------
68+
APP_NAME=FastKit App
69+
API_VERSION=v1
70+
MAX_FILE_SIZE=10MB

.pnpmrc

Whitespace-only changes.

CONFIGURATION.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ A comprehensive configuration management system for FastKit that allows you to c
1919
### Basic Usage
2020

2121
```typescript
22-
import { FastKitConfig, FastKitConfigData } from './config/FastKit.config';
22+
import { FastKitConfig, envType } from './config/FastKit.config';
2323

2424
// Create configuration
25-
const config: FastKitConfigData = {
25+
const config: envType = {
2626
server: {
2727
port: 3000,
2828
host: 'localhost',
@@ -58,12 +58,12 @@ console.log('Server port:', envConfig.server.port);
5858

5959
## Configuration Interfaces
6060

61-
### FastKitConfigData
61+
### envType
6262

6363
The main configuration interface that defines all possible configuration options:
6464

6565
```typescript
66-
interface FastKitConfigData {
66+
interface envType {
6767
server: ServerConfig; // Required: Server configuration
6868
database: DatabaseConfig; // Required: Database configuration
6969
jwt: JWTConfig; // Required: JWT configuration
@@ -156,7 +156,7 @@ interface EmailConfig {
156156
### 1. Create Development Configuration
157157

158158
```typescript
159-
const devConfig: FastKitConfigData = {
159+
const devConfig: envType = {
160160
server: {
161161
port: 3000,
162162
host: 'localhost',
@@ -188,7 +188,7 @@ await config.writeToEnv();
188188
### 2. Create Production Configuration
189189

190190
```typescript
191-
const prodConfig: FastKitConfigData = {
191+
const prodConfig: envType = {
192192
server: {
193193
port: parseInt(process.env.PORT || '8080'),
194194
host: '0.0.0.0',

jest.config.json

Whitespace-only changes.

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99
"dist"
1010
],
1111
"scripts": {
12-
"build": "tsc",
1312
"clean": "rimraf dist",
14-
"rebuild": "npm run clean && npm run build",
15-
"rebuild:pnpm": "pnpm run clean && pnpm run build",
13+
"build": "tsc && pnpm exec tsc-alias",
14+
"rebuild": "pnpm run clean && pnpm run build",
1615
"lint": "eslint src/**/*.{ts,tsx}",
1716
"lint:fix": "eslint src/**/*.{ts,tsx} --fix",
17+
"test": "jest",
1818
"test:watch": "jest --watch",
1919
"test:coverage": "jest --coverage",
20-
"start:dev": "ts-node-dev --respawn --transpile-only src/FastKit.ts",
20+
"start:dev": "ts-node -r tsconfig-paths/register src/FastKit.ts",
21+
"start:test": "ts-node --transpile-only src/test.ts",
2122
"format": "prettier --write 'src/**/*.{ts,tsx,js,json,md}'",
22-
"prepublishOnly": "npm run format && npm run lint && npm run build",
23+
"prepublishOnly": "pnpm run format && pnpm run lint && pnpm run build",
2324
"publish:npm": "npm publish --access public",
2425
"publish:pnpm": "pnpm publish --access public --no-git-checks",
2526
"version:patch": "npm version patch",
2627
"version:minor": "npm version minor",
27-
"version:major": "npm version major",
28-
"test": "jest"
28+
"version:major": "npm version major"
2929
},
3030
"keywords": [
3131
"api",
@@ -81,6 +81,8 @@
8181
"rimraf": "^6.0.1",
8282
"ts-jest": "^29.4.0",
8383
"ts-node-dev": "^2.0.0",
84+
"tsc-alias": "^1.8.16",
85+
"tsconfig-paths": "^4.2.0",
8486
"typescript": "^5.8.3",
8587
"typescript-eslint": "^8.35.0"
8688
},

0 commit comments

Comments
 (0)