Skip to content

Commit 014695b

Browse files
feat: Implement environment variable management and configuration loading
- Added EnvManager class for loading and managing environment variables. - Created index file for FastKit configuration module to streamline exports. - Removed outdated test suite for configuration system. - Updated database configuration types and validation functions. - Enhanced env.constant.ts to include additional environment variables and defaults. - Refactored env.types.ts to expand the EnvType interface with new properties. - Updated tsconfig.json to include all source files for compilation.
1 parent 4c2d031 commit 014695b

26 files changed

Lines changed: 864 additions & 1218 deletions

.env.example

Lines changed: 0 additions & 105 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- 'v*' # Optional: run on version tags like v1.0.0
9+
10+
jobs:
11+
publish:
12+
name: Publish to npm
13+
runs-on: ubuntu-latest
14+
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Use Node.js 18
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 18
24+
registry-url: 'https://registry.npmjs.org/'
25+
26+
- name: Setup pnpm
27+
uses: pnpm/action-setup@v2
28+
with:
29+
version: 8
30+
31+
- name: Install dependencies
32+
run: pnpm install
33+
34+
- name: Build package
35+
run: pnpm build
36+
37+
# - name: Run tests (optional)
38+
# run: pnpm test
39+
40+
- name: Authenticate with npm
41+
run: npm config set //registry.npmjs.org/:_authToken=${NPM_TOKEN}
42+
env:
43+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
45+
# Optional: Authenticate with GitHub Packages
46+
# - name: Authenticate with GitHub Packages
47+
# run: npm config set //npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
48+
# env:
49+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- name: Publish to npm
52+
run: pnpm publish --access public

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ CHANGELOG.md
2222
# Git files
2323
.git/
2424
.gitignore
25+
.env
26+
Environment/
2527

2628
# CI/CD
2729
.github/

.pnpmrc

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1-
# pnpm configuration
1+
# Avoid legacy-style hoisting unless absolutely needed
22
shamefully-hoist=false
3+
4+
# Loosen peer dependency requirements during dev
35
strict-peer-dependencies=false
6+
7+
# Automatically install required peer dependencies
48
auto-install-peers=true
9+
10+
# Save versions with ^ to allow non-breaking updates
511
save-exact=false
612
save-prefix=^
13+
14+
# Use isolated node_modules for better reproducibility
715
node-linker=isolated
16+
17+
# Use local workspace packages first (important for monorepos)
818
prefer-workspace-packages=true
9-
git-checks=true
19+
20+
# Ensures one lockfile for all workspace packages
21+
shared-workspace-lockfile=true
22+
23+
# Only publish from main (also declared in .npmrc)
1024
publish-branch=main

jest.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// jest.config.cjs
2+
export default {
3+
preset: 'ts-jest/presets/default-esm', // use ESM preset for ts-jest
4+
testEnvironment: 'node',
5+
extensionsToTreatAsEsm: ['.ts'],
6+
transform: {
7+
'^.+\\.ts$': ['ts-jest', { useESM: true }],
8+
},
9+
moduleNameMapper: {
10+
'^(\\.{1,2}/.*)\\.js$': '$1', // fix import extensions
11+
},
12+
};

jest.setup.ts

Whitespace-only changes.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "@abhishek-nexgen-dev/fastkit",
3+
"type": "commonjs",
34
"version": "1.0.1",
45
"description": "A modular, class-based toolkit for fast API development with TypeScript and Express.",
56
"main": "dist/FastKit.js",
@@ -61,7 +62,9 @@
6162
"@babel/core": "^7.27.7",
6263
"@babel/preset-env": "^7.27.2",
6364
"@eslint/js": "^9.29.0",
65+
"@jest/globals": "^30.0.3",
6466
"@types/express": "^5.0.3",
67+
"@types/jest": "^30.0.0",
6568
"@types/node": "^24.0.4",
6669
"@typescript-eslint/eslint-plugin": "^8.35.0",
6770
"@typescript-eslint/parser": "^8.35.0",
@@ -72,6 +75,7 @@
7275
"globals": "^16.2.0",
7376
"husky": "^9.1.7",
7477
"i": "^0.3.7",
78+
"jest": "^30.0.3",
7579
"lint-staged": "^16.1.2",
7680
"prettier": "^3.6.2",
7781
"rimraf": "^6.0.1",
@@ -81,11 +85,9 @@
8185
"typescript-eslint": "^8.35.0"
8286
},
8387
"dependencies": {
84-
"@jest/globals": "^30.0.3",
8588
"@types/dotenv": "^8.2.3",
8689
"dotenv": "^16.6.0",
8790
"express": "^5.1.0",
88-
"jest": "^30.0.3",
8991
"zod": "^3.25.67"
9092
}
9193
}

pnpm-lock.yaml

Lines changed: 17 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/FastKit.ts

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1 @@
1-
/**
2-
* FastKit - Type-Safe Configuration System
3-
*
4-
* This example demonstrates how to use FastKit's configuration system
5-
* that automatically reads and validates environment variables.
6-
*/
7-
8-
import { FastKitConfig } from './config/FastKit.config';
9-
import { EnvManager } from './config/env.manager';
10-
import { EnvConstants } from './constant/env.constant';
11-
12-
13-
14-
// Create Env directory if it doesn't exist and load .env files
15-
console.log('🔧 FastKit Type-Safe Configuration System\n');
16-
EnvManager.loadEnvFile();
17-
18-
19-
// Validate and load configuration from environment variables
20-
const configResult = FastKitConfig.validateEnv();
21-
22-
if (configResult.isValid) {
23-
console.log('✅ Configuration loaded successfully!');
24-
25-
26-
}
27-
28-
console.log(EnvConstants)
29-
// Generate sample .env file if needed
30-
if (!configResult.isValid) {
31-
console.log('\n📝 Generating sample .env file...');
32-
try {
33-
34-
console.log('✅ Sample .env.example file created. Copy it to .env and modify as needed.');
35-
} catch (error) {
36-
console.error('❌ Failed to generate sample .env file:', error);
37-
}
38-
}
39-
40-
1+
export * from './config/FastKit-Config';

0 commit comments

Comments
 (0)