|
1 | | -# 🚀 FastKit – Modular, Scalable API Toolkit with TypeScript + Express |
| 1 | +# 🚀 FastKit – Comprehensive Full-Stack Development Toolkit |
2 | 2 |
|
3 | | -FastKit is a **developer-first**, **class-based**, and **plug-and-play** toolkit built on top of Express and TypeScript to help you build APIs faster — with clean structure, reusable logic, and zero boilerplate. |
| 3 | +FastKit is a **developer-first**, **modular**, and **type-safe** toolkit for building modern applications with authentication, database management, and configuration handling out of the box. |
4 | 4 |
|
5 | | -✅ You can use `fastKit.get()`, `post()`, `put()`, `delete()` for defining routes |
6 | | -✅ All services, controllers, middlewares, and utilities are modular and importable |
7 | | -✅ No framework lock-in — write your own logic, inject nothing |
| 5 | +✅ **Authentication Module** – Complete auth system with controllers and services |
| 6 | +✅ **Database Config** – Multi-database support with type-safe configurations |
| 7 | +✅ **Environment Management** – Automated environment setup and configuration |
| 8 | +✅ **TypeScript First** – Full type safety across all modules |
| 9 | +✅ **Framework Agnostic** – Use with Express, Fastify, or any Node.js framework |
| 10 | +✅ **Tree-shakable** – Import only what you need for optimal bundle size |
8 | 11 |
|
9 | 12 | --- |
10 | 13 |
|
11 | | -## 🎯 Why Use FastKit? |
| 14 | +## 📦 Installation |
| 15 | + |
| 16 | +### Quick Start |
| 17 | +```bash |
| 18 | +npm install @nexgenstudiodev/fastkit |
| 19 | +``` |
12 | 20 |
|
13 | | -- 🧱 **Clean Architecture** – Organize your features like `Auth`, `Todo`, `Email`, etc. |
14 | | -- 🔁 **Reusable Everything** – Use any controller, validator, service, or utility anywhere |
15 | | -- 🧩 **Modular Setup** – Easily extend with your own modules |
16 | | -- 🧠 **Zero Magic** – No decorators, no complex DI, no auto-binding |
17 | | -- ⚡ **TypeScript First** – Type-safe from top to bottom |
18 | | -- 🌍 **Plug-and-Play** – Use just the parts you need |
| 21 | +### Requirements |
| 22 | +- Node.js 16+ |
| 23 | +- TypeScript 4.5+ (for TypeScript projects) |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## 🎯 Why Choose FastKit? |
| 28 | + |
| 29 | +- 🔐 **Complete Auth System** – Login, register, JWT handling, password reset |
| 30 | +- �️ **Multi-Database Support** – MongoDB, PostgreSQL, MySQL, SQLite, Redis |
| 31 | +- ⚙️ **Smart Configuration** – Environment-based config with auto-generation |
| 32 | +- 🧩 **Modular Architecture** – Use individual modules or the complete package |
| 33 | +- 🌍 **Universal Compatibility** – Works with CommonJS, ES Modules, and TypeScript |
| 34 | +- 📝 **Type Safety** – Full TypeScript support with comprehensive type definitions |
19 | 35 |
|
20 | 36 |
|
21 | 37 |
|
@@ -49,31 +65,251 @@ pnpm add @nexgenstudiodev/fastkit |
49 | 65 | yarn add @nexgenstudiodev/fastkit |
50 | 66 | ``` |
51 | 67 |
|
| 68 | +--- |
52 | 69 |
|
| 70 | +## 🚀 Quick Start Examples |
53 | 71 |
|
| 72 | +### JavaScript (CommonJS) |
| 73 | +```javascript |
| 74 | +const express = require('express'); |
| 75 | +const { |
| 76 | + auth, |
| 77 | + config, |
| 78 | + db, |
| 79 | + AuthController, |
| 80 | + setup_FastKit_EnvFiles |
| 81 | +} = require('@nexgenstudiodev/fastkit'); |
54 | 82 |
|
55 | | -## 🛠️ Getting Started |
| 83 | +const app = express(); |
56 | 84 |
|
57 | | -### 1. Create FastKit App |
| 85 | +// Setup environment files |
| 86 | +setup_FastKit_EnvFiles(); |
58 | 87 |
|
59 | | -````ts |
60 | | -// server.ts |
| 88 | +// Use auth controller |
| 89 | +app.post('/api/auth/login', auth.AuthController.login); |
| 90 | +app.post('/api/auth/register', auth.AuthController.register); |
| 91 | + |
| 92 | +// Database configuration |
| 93 | +const dbConfig = { |
| 94 | + type: 'mongodb', |
| 95 | + url: process.env.DATABASE_URL || 'mongodb://localhost:27017/myapp' |
| 96 | +}; |
| 97 | + |
| 98 | +app.listen(3000, () => { |
| 99 | + console.log('FastKit app running on port 3000'); |
| 100 | +}); |
| 101 | +``` |
| 102 | + |
| 103 | +### JavaScript (ES Modules) |
| 104 | +```javascript |
61 | 105 | import express from 'express'; |
62 | | -import { FastKit } from './fastkit'; |
63 | | -import { loadFastKitConfig } from './config/fastkit.config'; |
| 106 | +import { |
| 107 | + auth, |
| 108 | + config, |
| 109 | + db, |
| 110 | + AuthController, |
| 111 | + setup_FastKit_EnvFiles, |
| 112 | + FastKit |
| 113 | +} from '@nexgenstudiodev/fastkit'; |
| 114 | + |
| 115 | +const app = express(); |
| 116 | + |
| 117 | +// Setup environment and configuration |
| 118 | +setup_FastKit_EnvFiles(); |
| 119 | +const appConfig = new FastKit(); |
| 120 | + |
| 121 | +// Authentication routes |
| 122 | +app.post('/api/auth/login', AuthController.login); |
| 123 | +app.post('/api/auth/register', AuthController.register); |
| 124 | +app.post('/api/auth/logout', AuthController.logout); |
| 125 | + |
| 126 | +// Database setup |
| 127 | +const dbConfig = { |
| 128 | + type: 'postgresql', |
| 129 | + host: 'localhost', |
| 130 | + port: 5432, |
| 131 | + databaseName: 'myapp' |
| 132 | +}; |
| 133 | + |
| 134 | +app.listen(3000, () => { |
| 135 | + console.log('FastKit app running on port 3000'); |
| 136 | +}); |
| 137 | +``` |
| 138 | + |
| 139 | +### TypeScript |
| 140 | +```typescript |
| 141 | +import express, { Request, Response } from 'express'; |
| 142 | +import { |
| 143 | + auth, |
| 144 | + config, |
| 145 | + db, |
| 146 | + AuthController, |
| 147 | + AuthService, |
| 148 | + setup_FastKit_EnvFiles, |
| 149 | + FastKit, |
| 150 | + DatabaseConfig, |
| 151 | + DatabaseType, |
| 152 | + Config_Type |
| 153 | +} from '@nexgenstudiodev/fastkit'; |
64 | 154 |
|
65 | 155 | const app = express(); |
66 | | -const config = loadFastKitConfig(); |
67 | 156 |
|
68 | | -const fastKit = new FastKit(app, config); |
| 157 | +// Type-safe configuration |
| 158 | +setup_FastKit_EnvFiles(); |
| 159 | +const appConfig: Config_Type = new FastKit({ |
| 160 | + database: { |
| 161 | + type: 'mongodb', |
| 162 | + url: process.env.DATABASE_URL |
| 163 | + }, |
| 164 | + auth: { |
| 165 | + jwtSecret: process.env.JWT_SECRET || 'fallback-secret', |
| 166 | + expiresIn: '7d' |
| 167 | + } |
| 168 | +}); |
69 | 169 |
|
70 | | -// Your routes |
71 | | -import './apiRoutes'; |
| 170 | +// Type-safe database configuration |
| 171 | +const dbConfig: DatabaseConfig = { |
| 172 | + type: 'postgresql' as DatabaseType, |
| 173 | + host: 'localhost', |
| 174 | + port: 5432, |
| 175 | + username: 'admin', |
| 176 | + password: 'password', |
| 177 | + databaseName: 'myapp', |
| 178 | + ssl: true |
| 179 | +}; |
| 180 | + |
| 181 | +// Authentication with full type support |
| 182 | +app.post('/api/auth/login', AuthController.login); |
| 183 | +app.post('/api/auth/register', AuthController.register); |
72 | 184 |
|
73 | 185 | app.listen(3000, () => { |
74 | | - console.log('🚀 Server is running on http://localhost:3000'); |
| 186 | + console.log('TypeScript FastKit app running on port 3000'); |
75 | 187 | }); |
| 188 | +``` |
| 189 | + |
| 190 | +--- |
| 191 | + |
| 192 | +## 📚 Module Documentation |
| 193 | + |
| 194 | +### 🔐 Authentication Module |
| 195 | +Complete authentication system with controllers, services, and utilities. |
| 196 | + |
| 197 | +**Key Features:** |
| 198 | +- Login/Register endpoints |
| 199 | +- JWT token management |
| 200 | +- Password reset functionality |
| 201 | +- Authentication middleware |
| 202 | + |
| 203 | +**Quick Usage:** |
| 204 | +```javascript |
| 205 | +import { AuthController, AuthService } from '@nexgenstudiodev/fastkit'; |
| 206 | + |
| 207 | +// Use pre-built controllers |
| 208 | +app.post('/login', AuthController.login); |
| 209 | +``` |
| 210 | + |
| 211 | +**[📖 Full Auth Documentation](src/packages/fastkit-auth/README.md)** |
| 212 | + |
| 213 | +### ⚙️ Configuration Module |
| 214 | +Smart configuration management with environment handling. |
76 | 215 |
|
| 216 | +**Key Features:** |
| 217 | +- Automatic environment file generation |
| 218 | +- Type-safe configuration objects |
| 219 | +- Environment-specific settings |
| 220 | +- Configuration validation |
| 221 | + |
| 222 | +**Quick Usage:** |
| 223 | +```javascript |
| 224 | +import { setup_FastKit_EnvFiles, FastKit } from '@nexgenstudiodev/fastkit'; |
| 225 | + |
| 226 | +// Auto-generate .env files |
| 227 | +setup_FastKit_EnvFiles(); |
| 228 | + |
| 229 | +// Type-safe configuration |
| 230 | +const config = new FastKit(); |
| 231 | +``` |
| 232 | + |
| 233 | +**[📖 Full Config Documentation](src/packages/fastkit-config/README.md)** |
| 234 | + |
| 235 | +### 🗄️ Database Configuration Module |
| 236 | +Multi-database support with type-safe configurations. |
| 237 | + |
| 238 | +**Key Features:** |
| 239 | +- Support for MongoDB, PostgreSQL, MySQL, SQLite, Redis |
| 240 | +- Type-safe database configurations |
| 241 | +- Connection string generation |
| 242 | +- Environment-based setup |
| 243 | + |
| 244 | +**Quick Usage:** |
| 245 | +```javascript |
| 246 | +import { DatabaseConfig, DatabaseType } from '@nexgenstudiodev/fastkit'; |
| 247 | + |
| 248 | +const dbConfig: DatabaseConfig = { |
| 249 | + type: 'mongodb', |
| 250 | + url: process.env.DATABASE_URL, |
| 251 | + options: { useNewUrlParser: true } |
| 252 | +}; |
| 253 | +``` |
| 254 | + |
| 255 | +**[📖 Full Database Config Documentation](src/packages/fastkit-db-config/README.md)** |
| 256 | + |
| 257 | +--- |
| 258 | + |
| 259 | +## 🎯 Import Flexibility |
| 260 | + |
| 261 | +FastKit supports multiple import patterns for maximum flexibility: |
| 262 | + |
| 263 | +### Main Package Imports |
| 264 | +```javascript |
| 265 | +// Everything from main package |
| 266 | +import { auth, config, db, AuthController, FastKit } from '@nexgenstudiodev/fastkit'; |
| 267 | +``` |
| 268 | + |
| 269 | +### Sub-module Imports (Tree-shaking) |
| 270 | +```javascript |
| 271 | +// Import only what you need |
| 272 | +import { AuthController } from '@nexgenstudiodev/fastkit/auth'; |
| 273 | +import { FastKit } from '@nexgenstudiodev/fastkit/config'; |
| 274 | +import { DatabaseConfig } from '@nexgenstudiodev/fastkit/db'; |
| 275 | +``` |
| 276 | + |
| 277 | +### Namespace Imports |
| 278 | +```javascript |
| 279 | +// Organized by module |
| 280 | +import { auth, config, db } from '@nexgenstudiodev/fastkit'; |
| 281 | + |
| 282 | +const controller = auth.AuthController; |
| 283 | +const dbConfig = db.DatabaseConfig; |
| 284 | +``` |
| 285 | + |
| 286 | + |
| 287 | + |
| 288 | + |
| 289 | +## 🛠️ Getting Started |
| 290 | + |
| 291 | +### 1. Create FastKit App |
| 292 | + |
| 293 | +````ts |
| 294 | +// server.js |
| 295 | + |
| 296 | +import express from 'express'; |
| 297 | +const app = express(); |
| 298 | +import { FastKit , setup_FastKit_EnvFiles , Config_Type } from '@nexgenstudiodev/fastkit/config'; |
| 299 | + |
| 300 | + |
| 301 | +setup_FastKit_EnvFiles() |
| 302 | +const fastKit = new FastKit(app); |
| 303 | + |
| 304 | +fastKit.get('/', (req, res) => { |
| 305 | + res.send('Hello World!'); |
| 306 | +} |
| 307 | + |
| 308 | +); |
| 309 | + |
| 310 | +fastKit.listen(3000, () => { |
| 311 | + console.log('Server is running on http://localhost:3000'); |
| 312 | +}); |
77 | 313 |
|
78 | 314 | ```` |
79 | 315 |
|
|
0 commit comments