CacheKit provides reusable caching utilities and integrations for NestJS services.
- ✅ CSR Architecture - Controller-Service-Repository pattern
- ✅ TypeScript - Strict mode with path aliases
- ✅ Testing - Jest with 80% coverage threshold
- ✅ Code Quality - ESLint + Prettier + Husky
- ✅ Versioning - Changesets for semantic versioning
- ✅ CI/CD - GitHub Actions workflows
- ✅ Documentation - Complete Copilot instructions
- ✅ Examples - Full working examples for all layers
# Clone CacheKit
git clone https://github.com/CISCODE-MA/CacheKit.git cachekit
cd cachekit
# Install dependencies
npm install
# Start developing
npm run build
npm testsrc/
├── index.ts # PUBLIC API exports
├── {module-name}.module.ts # NestJS module definition
│
├── controllers/ # HTTP Layer
│ └── example.controller.ts
│
├── services/ # Business Logic
│ └── example.service.ts
│
├── entities/ # Domain Models
│ └── example.entity.ts
│
├── repositories/ # Data Access
│ └── example.repository.ts
│
├── guards/ # Auth Guards
│ └── example.guard.ts
│
├── decorators/ # Custom Decorators
│ └── example.decorator.ts
│
├── dto/ # Data Transfer Objects
│ ├── create-example.dto.ts
│ └── update-example.dto.ts
│
├── filters/ # Exception Filters
├── middleware/ # Middleware
├── config/ # Configuration
└── utils/ # Utilities
// src/example-kit.module.ts
import { Module, DynamicModule } from "@nestjs/common";
import { ExampleService } from "@services/example.service";
@Module({})
export class ExampleKitModule {
static forRoot(options: ExampleKitOptions): DynamicModule {
return {
module: ExampleKitModule,
providers: [ExampleService],
exports: [ExampleService],
};
}
}// src/services/example.service.ts
import { Injectable } from "@nestjs/common";
@Injectable()
export class ExampleService {
async doSomething(data: string): Promise<string> {
return `Processed: ${data}`;
}
}// src/dto/create-example.dto.ts
import { IsString, IsNotEmpty } from "class-validator";
export class CreateExampleDto {
@IsString()
@IsNotEmpty()
name: string;
}// src/index.ts
export { ExampleKitModule } from "./example-kit.module";
export { ExampleService } from "./services/example.service";
export { CreateExampleDto } from "./dto/create-example.dto";# Development
npm run build # Build the package
npm run build:watch # Build in watch mode
npm run typecheck # TypeScript type checking
# Testing
npm test # Run tests
npm run test:watch # Run tests in watch mode
npm run test:cov # Run tests with coverage
# Code Quality
npm run lint # Run ESLint
npm run format # Check formatting
npm run format:write # Fix formatting
# Release
npx changeset # Create a changeset
npm run release # Publish to npm (CI does this)This template uses Changesets for version management.
git checkout develop
git checkout -b feature/my-feature
# Make your changesnpx changesetSelect the change type:
- patch - Bug fixes
- minor - New features (backwards compatible)
- major - Breaking changes
git add .
git commit -m "feat: add new feature"
git push origin feature/my-feature
# Create PR → develop- Automation opens "Version Packages" PR
- Merge to
masterto publish
Tests are MANDATORY for all public APIs.
// src/services/example.service.spec.ts
describe("ExampleService", () => {
let service: ExampleService;
beforeEach(async () => {
const module = await Test.createTestingModule({
providers: [ExampleService],
}).compile();
service = module.get(ExampleService);
});
it("should be defined", () => {
expect(service).toBeDefined();
});
it("should process data correctly", async () => {
const result = await service.doSomething("test");
expect(result).toBe("Processed: test");
});
});Coverage threshold: 80%
Configured in tsconfig.json:
import { ExampleService } from "@services/example.service";
import { CreateExampleDto } from "@dtos/create-example.dto";
import { Example } from "@entities/example.entity";
import { ExampleRepository } from "@repos/example.repository";Available aliases:
@/*→src/*@controllers/*→src/controllers/*@services/*→src/services/*@entities/*→src/entities/*@repos/*→src/repositories/*@dtos/*→src/dto/*@guards/*→src/guards/*@decorators/*→src/decorators/*@config/*→src/config/*@utils/*→src/utils/*
- ✅ Input validation on all DTOs (class-validator)
- ✅ Environment variables for secrets
- ✅ No hardcoded credentials
- ✅ Proper error handling
- ✅ Rate limiting on public endpoints
This template includes comprehensive Copilot instructions in .github/copilot-instructions.md:
- Module architecture guidelines
- Naming conventions
- Testing requirements
- Documentation standards
- Export patterns
- Security best practices
- Architecture - Detailed architecture overview
- Release Process - How to release versions
- Copilot Instructions - AI development guidelines
- Rename the module: Update
package.jsonname - Update description: Modify
package.jsondescription - Configure exports: Edit
src/index.ts - Add dependencies: Update
peerDependenciesanddependencies - Customize structure: Add/remove directories as needed
✅ DO export:
- Module
- Services
- DTOs
- Guards
- Decorators
- Types/Interfaces
❌ DON'T export:
- Entities
- Repositories
Entities and repositories are internal implementation details.
- MAJOR (x.0.0) - Breaking changes
- MINOR (0.x.0) - New features (backwards compatible)
- PATCH (0.0.x) - Bug fixes
- All tests passing (80%+ coverage)
- No ESLint warnings
- TypeScript strict mode passing
- All public APIs documented (JSDoc)
- README updated
- Changeset created
- Breaking changes documented
-
.env.exampleupdated (if needed)
MIT
See CONTRIBUTING.md
Made with ❤️ by CisCode