π A powerful, extensible Node.js/TypeScript framework built for scalability, with advanced features and ready for enterprise integrations.
- Core Features
- Installation
- Documentation
- Architecture
- Integration Patterns
- Roadmap
- Contributing
- License
- Fine-grained permission control using CASL
- Role-based access control (RBAC) integration
- Dynamic ability checks for all CRUD operations
- Declarative permission definitions
Introducing a powerful baseHandler that provides:
// Example usage
import baseHandler from '../utils/baseHandler';
router.post('/', baseHandler.createOne(YourModel, {
auth: true,
ability: true,
discriminator: {
field: 'type',
models: { /* your model mapping */ }
}
}));createOne: Single document creationcreateMany: Bulk document creationgetAll: Smart paginated listinggetOne: Single document retrievalupdateOne: Document updatesdeleteOne: Single document deletiondeleteMany: Bulk deletiongetSelf: Current user document
- Automatic Population:
// Automatically detects and populates references const data = await Model.findById(id).populate(autoDetectedFields);
- Dynamic Search:
// Example search query GET /api/v1/resources?search={"keyword":"search","fields":["name","description"]}
- Complex Filtering:
// Support for complex query parameters GET /api/v1/resources?query={"status":"active"}&options={"sort":"createdAt"}
- Type discrimination for flexible data modeling
- Automatic audit trails (createdBy/updatedBy)
- Extensible authentication system
- Ready for multiple integration patterns
-
Clone the repository:
git clone https://github.com/miirshe/nexus-express-typescript.git cd nexus-express-typescript -
Install dependencies:
npm install # or yarn install -
Set up environment variables:
cp .env.example .env
-
Start development server:
npm run dev # or yarn dev
interface HandlerOptions {
auth?: boolean; // Enable/disable authentication
ability?: boolean; // Enable/disable authorization
discriminator?: {
field: string; // Field for type discrimination
models: { [key: string]: Model<any> }; // Model mapping
};
}- Create with Type Discrimination:
POST /api/v1/resources
{
"type": "custom",
"name": "Example Resource",
"metadata": { /* custom fields */ }
}- Smart Search:
GET /api/v1/resources?search={"keyword":"example","fields":["name","metadata"]}- Complex Queries:
GET /api/v1/resources?query={"status":"active"}&options={"sort":"-createdAt","populate":"relations"}- Authentication checks in every handler
- CASL-based authorization
- Type-safe implementations
- Request validation
- Error handling with proper status codes
- Authentication providers
- Notification systems
- External APIs
- Message queues
- Caching layers
- Monitoring systems
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Nexus Express TypeScript β
βββββββββββββββ¬ββββββββββββββ¬βββββββββββββββββ¬ββββββββββββββββ€
β API Layer β Services β Data Layer β Integrations β
βββββββββββββββΌββββββββββββββΌβββββββββββββββββΌββββββββββββββββ€
β β’ REST API β β’ Business β β’ MongoDB β β’ Auth β
β β’ GraphQL β Logic β β’ Redis Cache β Providers β
β β’ WebSocket β β’ Validationβ β’ Elasticsearchβ β’ Payment β
β β’ gRPC β β’ CASL Auth β β’ Queue System β Gateways β
βββββββββββββββ΄ββββββββββββββ΄βββββββββββββββββ΄ββββββββββββββββ
-
API Layer
- REST endpoints with OpenAPI/Swagger
- Optional GraphQL support
- Real-time WebSocket capabilities
- gRPC for microservices
-
Service Layer
- Business logic isolation
- CASL-based authorization
- Service-to-service communication
- Event handling
-
Data Layer
- MongoDB with Mongoose
- Redis for caching
- Elasticsearch for search
- Message queues
-
Integration Layer
- Authentication providers
- Payment systems
- External APIs
- Monitoring systems
// Support for multiple auth strategies
interface AuthProvider {
initialize(): Promise<void>;
authenticate(credentials: any): Promise<User>;
verify(token: string): Promise<boolean>;
}
// Implementation examples:
class JWTAuthProvider implements AuthProvider { ... }
class OAuth2Provider implements AuthProvider { ... }
class SAMLProvider implements AuthProvider { ... }// Unified notification interface
interface NotificationChannel {
send(message: NotificationMessage): Promise<void>;
}
// Multiple channel support
class EmailNotification implements NotificationChannel { ... }
class SMSNotification implements NotificationChannel { ... }
class PushNotification implements NotificationChannel { ... }// Generic payment interface
interface PaymentGateway {
processPayment(payment: Payment): Promise<Transaction>;
refund(transaction: Transaction): Promise<Refund>;
}
// Multiple provider support
class StripeGateway implements PaymentGateway { ... }
class PayPalGateway implements PaymentGateway { ... }// Flexible caching interface
interface CacheProvider {
get<T>(key: string): Promise<T>;
set<T>(key: string, value: T, ttl?: number): Promise<void>;
}
// Implementation examples:
class RedisCache implements CacheProvider { ... }
class MemcachedCache implements CacheProvider { ... }- CASL Integration
- Dynamic CRUD Operations
- Type Discrimination
- Smart Data Handling
- Multi-factor Authentication
- OAuth2 Provider Integration
- SAML Support
- Rate Limiting
- API Key Management
- Redis Caching Layer
- Elasticsearch Integration
- Message Queue System
- Horizontal Scaling Support
- GraphQL API Layer
- OpenAPI/Swagger Documentation
- CLI Tool for Code Generation
- Development Container Support
- Enhanced Debugging Tools
- Integration Test Framework
- Audit Logging System
- Business Event System
- Workflow Engine
- Report Generation
- Data Export/Import
- APM Integration
- Metrics Collection
- Alert System
- Log Aggregation
- Performance Analytics
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.